-
Notifications
You must be signed in to change notification settings - Fork 50
Description
I've had success in using this PowerShell script to pack the PATH environment variable, in order to support more directories, and thought I would share it.
clear
write-host "Reading..."
write-host
$fso = New-Object -ComObject "Scripting.FileSystemObject"
$shortpaths = @();
$originalPaths = [environment]::GetEnvironmentVariable("path", "Machine").Split(";")
foreach ($path in $originalPaths) {
$fpath = [System.IO.Path]::GetFullPath("$path");
$fspath = $fso.GetFolder("$fpath").ShortPath;
$foundIdx = $shortpaths.IndexOf($fspath);
if ($foundIdx -gt -1) { continue; }
write-host $fpath --> $fspath;
$shortpaths += $fspath;
}
write-host
write-host "Packing..."
write-host
write-host $env:Path
write-host
write-host "Done."
write-host