Last active
April 19, 2016 23:50
-
-
Save a5ync/c9b32504f2f55aba079d6f3b443d4942 to your computer and use it in GitHub Desktop.
Adding a new path to environment variable Path (Machine or User space)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$newPath = "c:\scripts\" | |
Write-host Preparing environment | |
$currentPath = [Environment]::GetEnvironmentVariable("Path",[EnvironmentVariableTarget]::User) #or ::Machine | |
if ($currentPath -like '*'+$newPath+'*') | |
{ | |
Write-host 'System environment "Path" already contains ' $newPath | |
} | |
else { | |
Write-host 'Adding ' $newPath ' to System "Path"' | |
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";"+$newPath, [EnvironmentVariableTarget]::User) #or ::Machine | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment