Saturday, November 9, 2013

What happens with Path System Variable is too long?

Nothing is more disconcerting than an error message when attempting to use basic Windows features.  I was greeted this morning by an error when trying to open SSMS 2012 after I just installed it: "Exception has been thrown by target of an invocation."  Googling the error didn't return much helpful information except to suggest that I needed to adjust my PATH system environment variable.  So I decided the next best thing would be to review my path variable.

In Windows 7, the standard way I get to environment variables is through the "Advanced System Settings" option in Computer -> Properties:


Imagine my surprise when I get this instead: "Windows cannot find '%windir%\system32\systempropertiesadvanced.exe'. Make sure you typed the name correctly, and then try again."  What!?  Did I corrupt my Windows 7 installation again and I have to start all over?  Thankfully, no.

Turns out, the root cause was my installation of SSMS 2012 put the length of the PATH variable just above the maximum limit.  When the PATH variable is too long, it stops resolving %PATH% properly, as well as any other environment variable.  I could test this by literally going to Command Prompt and typing "echo %PATH%."  The result coming back was "%PATH%" instead of expanding the environment variable as it normally would.

To get it working, I manually went directly to the path %windir%\system32\systempropertiesadvanced.exe, by navigating to c:\windows (%windir%) in Windows Explorer.  I could open the program from there, go to the PATH editor, and remove all the extra junk to make the variable a more manageable length.  Once I did that, my "Advanced System Settings" started working again, as did SSMS 2012.  Crisis averted!

Happy programming!

5 comments:

  1. Alternatively, you can use Long Path Tool, it works good for such problems I will say.

    ReplyDelete
  2. Damien barifon
    Try to long path tool. It is very helpful.

    ReplyDelete
  3. You can also use Long Path Tool to sort out this problem.

    ReplyDelete
  4. Thank you for sharing wonderful information with us to get some idea about it.
    Ui Path Online Training

    ReplyDelete
  5. "Long path tool" is popular program software. Sometimes you get an error when trying to move, delete, or copy directories where the character count for the file path is more than 260.

    ReplyDelete