📜 Identifying and resolving dead path links in Windows

April 8, 2020  List dead path links in Windows

If you are getting a "The system cannot find the path specified" after updating your %PATH% variable (or perhaps a pesky application like Anaconda broke your path), then it can be a pain to work out which exact directory on path needs to be updated. Windows doesn’t make this easy out of the box.

I found this Powershell gem on Stack https://stackoverflow.com/a/43815216/4524425

$env:Path -split ";" | % {"$(test-path $_);$_"}

generating this kind of output which you can independently verify

False;C:\Program Files (x86)\Java\jre7\bin

to reassemble for updating Path:

$x=$null;foreach ($t in ($env:Path -split ";") ) {if (test-path $t) {$x+=$t+";"}};$x