Skip to content

PATH too long #46

@mycall

Description

@mycall

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
$env:Path = $($shortpaths -join ";");
write-host $env:Path
write-host
write-host "Done."
write-host

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions