Non-existant directories in System PATH variable

swiftie

Old git Member
Member
VIP
Local time
10:35 PM
Messages
149
Location
Hampshire, England
"echo %PATH%" gives me a list of 32 directories.
12 of these don't exist on my system, for example: C:\Windows\System32\WindowsPowerShell\v1.0\

Is there any reason to keep these directories in my System PATH variable?
Is something likely to come along wanting to use one of these directories?
Do the missing directories have any significant performance penalties?

I only came across this when I wanted to add a new directory to the PATH, and was faced with editing a huge string in a tiny input area (inside "System" in the Administrator Tools). Perhaps there's an easier way to manipulate the PATH variable?
 
Last edited:

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
Hi, Swiftie, again,

The path you claim that does not exist on your system, should. C:\Windows\System32\WindowsPowerShell\v1.0 is where powershell.exe lives, and PowerShell exists on all versions and variants of Windows 7.

Verify you have PowerShell by running it. Or attempt to call to it through the command prompt. E.g execute the command powershell -?. If you successfully start PowerShell using either method, type the following command at the command line, where powershell. This will return the path to the PowerShell interpreter (which should be "C:\Windows\System32\WindowsPowerShell\v1.0" exactly).


Is there any reason to keep these directories in my System PATH variable
Is something likely to come along wanting to use one of these directories?
Do [] missing directories have any significant performance penalties?
Yes, yes and yes.


Perhaps there's an easier way to manipulate the PATH variable?
If you are comfortable with using the command line, there is the SETX command which is used to set persistent environment variables. The following is an example of how one would go about appending a path to the PATH variable,
Code:
setx "PATH" "%PATH%;C:\my\path" /m
But I highly recommend you do not use setx to make edits to existing environment variables. Things can wrong. Use setx to create new environment variables.


Note 1: A popular way of viewing the contents of the PATH variable is to echo out the following variable,
Code:
%PATH:;=&echo.%

Note 2: In the PATH variable, please do not add a semicolon after the last entry in the list of directory paths.
 
Last edited:

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Turns out that the API that I use to verify the existence of a directory doesn't tolerate a trailing '\' character on a directory name.

So, I have a bypass - remove trailing '\' characters before passing the directory name to the API. Directory C:\Windows\System32\WindowsPowerShell\v1.0 does exist on my system.

But this just raises another question... Should the directory name in the PATH variable have the trailing '\' removed, or should the API (or my code) be more tolerant?

I've come across a version of this quandary whilst configuring the Apache webserver. In places where you specify directory names, you have to include the trailing '\'. Or omit it, I forget which. Oh, you can also use '/' if you prefer.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
Typically a path that includes a trailing backslash is considered incorrect. I'm not too sure why the PowerShell path entry in the PATH variable includes a trailing backslash by default.

You should always stick to the path naming conventions, however, your API could indeed be more tolerant and understand paths that include a trailing backslash.

Is there some "get unresolved path" or "normalise path" function you can incorperate in your API that will tidy up paths and trim any excess backslashes from them?
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
... Is there some "get unresolved path" or "normalise path" function you can incorperate in your API that will tidy up paths and trim any excess backslashes from them?

Having got a directory name into a variable ("dir" say) then strip(dir,'T','\') will strip off trailing backslashes.

The language I use is REXX, developed by IBM, and I worked for IBM in its formative period onwards. The beta testers wanted a rich variety of text-handling functions, and we got them.

I'll admit that my code sometimes stores directory paths with a trailing '\'. That way, if you're generating fully qualified filenames from this directory and the name of the file, you just concatenate the directory name and the file name, without having to worry about including the '\' in between. It seems more efficient this way, and coding this way must have saved my PC at least a millisecond of CPU time, over the decades... :D
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
Back
Top