Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Non-existant directories in System PATH variable

01 Feb 2015   #1
swiftie

Windows 7 Ultimate x64
 
 
Non-existant directories in System PATH variable

"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?


My System SpecsSystem Spec
.
02 Feb 2015   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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).


Quote   Quote: Originally Posted by swiftie View Post
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.


Quote   Quote: Originally Posted by swiftie View Post
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.
My System SpecsSystem Spec
02 Feb 2015   #3
swiftie

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
.

03 Feb 2015   #4
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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 System SpecsSystem Spec
03 Feb 2015   #5
swiftie

Windows 7 Ultimate x64
 
 

Quote   Quote: Originally Posted by Pyprohly View Post
... 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...
My System SpecsSystem Spec
Reply

 Non-existant directories in System PATH variable




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
accidentally deleted PATH variable
Not sure if this is the right forum, I don't see any forum for troubleshooting. I was trying to edit my PATH environment variable and accidentally deleted it. Is there any way to recover it? If not, is there anyone out there who can tell me what the default path variable should be? I'm afraid to...
General Discussion
Trying to understand behavior of current directory and PATH variable.
The PATH variable on my machine is set to C:\Perl64\site\bin;C:\Perl64\bin;C:\Windows\System32;C:\Program Files\Java\jdk1.7\bin;C:\Program Files (x86)\Notepad++; I have a batch file (batchfile.bat) with the following commands - dir path notepad++ source.frm -n2150 PAUSE
General Discussion
Path Variable For Installing Dig Instead OF Using NSLookup
Hey folks Just wondering if anyone can tell me if it is OK to have (create) a second PATH environment variable for Dig. I currently have 1 PATH variable already being c:\Program Files (x86)\Nmap. In the instructions for installing Dig found here dig, a DNS query tool for Windows and...
Software
Cannot find the system variable path.
Hi. Running windows 7 ultimate 32bit. I want to add to path per this below, but I cannot find the path per the info here: How do I that ?
General Discussion
Adding Directories to Path Failure
How do you actually add directories to path? Every tutorial I've come across just says tack the path on to the end of the PATH variable after the previous variable's semicolon. That doesn't work. For instance if I want to add a path B:\MinGW\bin\ I would just add it to the system variable PATH like...
Performance & Maintenance


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:33.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App