Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've encountered a strange issue - I can't launch Visual Studio, nor run simple commands from command prompt, seemingly due to my PATH variable being too long. Now that I look at it, I see that many companies have added their install directories to the PATH variable.

I was wondering why these companies added their folders to the path (perhaps to make it simpler to execute their programs?), and which are necessary and which I can delete. If I delete some of them, will I not be able to launch the programs? (Here's what currently exists in the path)

share|improve this question
1  
I really don't feel like that's a particularly long PATH... What leads you to suspect that it's too long? Is VS throwing down some sort of error? Also, what version of Windows are you running? –  boscho Aug 22 '13 at 2:06
    
@bosco I suspect it's too long because command prompt can't find simple commands such as ping. Also, it seems that this isn't uncommon with visual studio. It was also mentioned here that the limit for the PATH using command line is around 2000. –  CC Inc Aug 22 '13 at 2:11
    
Visual studio 2012 throws the error "Exception has been thrown by target of an invocation" on startup. And when I looked in the ActivityLog.xml, it told me The type initializer for 'Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService' threw an exception. –  CC Inc Aug 22 '13 at 2:12
1  
All sorts of hacks and solutions in the accepted answer of Stack Overflow question #4405091 :) –  boscho Aug 22 '13 at 18:31

1 Answer 1

up vote 4 down vote accepted

To reduce the excessive quantity of paths in the environment variables PATH , just save the whole line out to a notepad, and remove some and test.

Most of them are there so if a shortcut does not have a full path set for the "Target", If the "Start In" is not set in the shortcut correctly or a launch is done oddly their program and its parts and pieces are always found. It is a Failsafe in most situations.

That set of paths WAS limited to less than 255(or260) charachters (if I remember correct) , that changed to 1024 some time long ago, then was patched back in server'03 era to handle 2048 , and supposedly could handle 8096? I am trying to sort out the facts still.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx here Microsoft says:

"The maximum size of a user-defined environment variable is 32,767 characters. There is no technical limitation on the size of the environment block. However, there are practical limits depending on the mechanism used to access the block. For example, a batch file cannot set a variable that is longer than the maximum command line length."

At that location ^ they specifically point to the registry location that contains the system paths HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment Must read the rest of it there.

After reading that, I would think it is not length that was the reasons people have broken this, but that removing something that broke how it worked, was what fixed it.

Too many folder paths in Path Variable? At this location Surfasb states:

BTW, while the OS has a limit of 32,767 for the PATH variable, the Command Prompt has a much much shorter length, somewhere around 2,000. I don't know the exact number.

Also see http://support.microsoft.com/kb/830473, which discusses the command prompt and batch length for older systems.

To make sure that the entries are correct in there, The wiki has this to say:
http://en.wikipedia.org/wiki/Environment_variable

%PATH% This variable contains a semicolon-delimited (do not put spaces in between) list of directories in which the command interpreter will search for an executable file that matches the given command. Environment variables that represent paths may be nested within the PATH variable but only at one level of indirection. If this subpath environment variable itself contains an environment variable representing a path, PATH will not expand properly in the variable substitution.

Having all the extra paths in there slows certain things down by quite a bit, because it is then forced to look in all those places, before it gives up. Using full paths whenever possible will always be faster, even when batching or using the CMDprompt.

Here is how mine looks, it has been worse.
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\

I would toss out quicktime in a heartbeat, and AMDs programs have put an extended path in there before, tossed it, it did not mater.

share|improve this answer
    
So you are saying that the applications will not fail if I remove the paths? –  CC Inc Aug 22 '13 at 2:15
    
Hang on, I have never seen so many paths in my life stuffed into there.Although I have seen it broken, from too many, . Lets be sure were talking about the same thing. And see if anyone else objects. Which windows system is it? –  Psycogeek Aug 22 '13 at 2:19
    
Windows 7 64-bit –  CC Inc Aug 22 '13 at 2:21
    
Is there anything in there you know is already uninstalled? Take out Qt, AMd And Nividia, (after you backed it up) mabey and see if it is short enough then? I posted mine, it is about 140 characters. –  Psycogeek Aug 22 '13 at 2:30
    
Okay, I'll see.. –  CC Inc Aug 22 '13 at 2:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.