ur0n2 / dotfiles-for-windows

dotfiles for windows
MIT License
6 stars 0 forks source link

환경변수 추가 체크 #19

Closed ur0n2 closed 7 years ago

ur0n2 commented 7 years ago

새로 변수하나 만들어서 Path에 추가식으로

ur0n2 commented 7 years ago

@1 $add_path = write-output $env:systemdrive"\linked" Environment::SetEnvironmentVariable("Path", $env:Path + $add_path, "Machine")

@2 add

Environment::GetEnvironmentVariable("Path", "Machine")

$add_path = write-output $env:systemdrive"\linked" Environment::SetEnvironmentVariable("ur0n2", $add_path, "Machine")

@3 $curr_path = @(Environment::GetEnvironmentVariable("Path", "Machine")) -split ";" #$curr_path = @($env:Path) -split ";" $curr_path if ($curr_path -contains $env:ur0n2){ write-output "Pass" }else{

Environment::SetEnvironmentVariable("Path", $env:Path + $env:ur0n2, "Machine") Environment::GetEnvironmentVariable("Path", "Machine") #$env:path is current powershell session, therefore different [Environ~]::GetEnv~ and $env:path. "[Environ~]::Get" is Dependency System Environment Variables }

ur0n2 commented 7 years ago

@3으로 현재 시스템(Machine)변수 Path에 ur0n2로 \linked 생성하고 Path에 ur0n2 추가 있으면 추가 안함