Skip to content

Instantly share code, notes, and snippets.

@aldente39
Created April 6, 2012 14:13
Show Gist options
  • Save aldente39/2320201 to your computer and use it in GitHub Desktop.
Save aldente39/2320201 to your computer and use it in GitHub Desktop.
add path
function AddPath([string]$x){
$p = pwd
$name = "Path"
sl HKCU:
$s = Get-ItemProperty "HKCU:Environment" $name
sl $p
$s = $s.$name
Write-Host "path length:" $s.length + $x.length
if(($s.length -eq 0) -or ($s[-1] -eq ";")){
$s += $x
setx $name $s
}
else{
$s += ";" + $x
setx $name $s
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment