3
votes

For some reason I do not know, my echo %path% has many duplicates of C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\. As far as I know, long %path% is bad because it slows the searching process. Is it safe to remove these duplicates?

I also noticed that there are two version of path variable: one for user variables and one for system variables. If I type echo %path% in command prompt as normal user, it will show the concatenation of these two version (system version comes first). If I am to remove the duplicates, from which version should I remove?

(bold one is system version)

C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\MinGW\bin;C:\Python27;C:\Users\jie\AppData\Local\Microsoft\WindowsApps

2
Wonky installers are notorious for destroying the PATH system variable. Intel in particular is a ravenous name dropper and abusing the hell out of PATH. Just fix it with Control Panel > System > Advanced > Environment variables.Hans Passant
Run => %windir%\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariablesAndrew
Related: superuser.com/questions/1223976/… (How to remove PATH duplicates)np8

2 Answers

1
votes

The paths you mention are system paths. They should stay in the PATH variable in the system scope. You can remove the duplicates in the PATH variable of the user scope, but you should reboot and check, if every application is still working (not because you deleted a duplicate, but to make sure you didn't delete something wrong by mistake). As usual, backup your PATH variables somewhere, before you start.

Duplicates inside each scope can always be safely removed. The list is split at every semicolon and each resulting path in the list is searched. If there are duplicates, the same search simply executes twice in the worst case. In the best case, the system might recognize the duplicates (I'm not sure if this happens), but this would mean additional effort for recognizing. So your statement on slowing down is correct in any case.

The reason for you duplicates (if it wasn't you at least) might probably be some application you installed somewhen, which edited the PATH variable improperly.

3
votes

On Microsoft Technet (Scriptcenter) is also a small PowerShellScript which checks against duplicate paths: How to check for duplicate paths in PATH environment variable

Should be run in a PowerShell environment with admin rights. I do this after every uninstall of any software (Windows 10 x64).