So after one of the latest installs / updates I started having weird issues on my computer – some were just annoying, some were critical and didn’t allow for programs to even open – such as Visual Studio throwing the oh-so-helpful exception of “Exception has been thrown by the target of an invocation”… If that wasn’t clear – well what is?!?!
Here were other symptoms:
- Unable start Visual Studio 2012, Visual Studio 2010 SP1 and SQL Server Management Studio 2012
- Missing icons for Windows Explorer on the taskbar, icons for some of the other tools (Services, Event Viewer, etc.)
- From the Command Prompt or when running batch files – XCopy and other commands stopped working.
Have you guessed the fix for this yet? No? Me neither… So I “Googled” it on BING and came up with the following nugget of… well I would say gold, but you all will soon know that I’m thinking it was a nugget of…
“A path environment variable cannot exceed 2048 characters”… say what? Really? Is this y2k’s revenge?
So – I went to look at my “Environment Variables” – which I usually get to by just typing “Environment Variables” in the “Search Programs and Files” under the “Start” menu – but alas, that command too was broken… lol…
So the fix:
1) If you can’t get there the easy way then you can bring up the Environment Variables from the command prompt by running “C:\Windows\System32\SystemPropertiesAdvanced.exe”
2) “System Properties” dialog comes up – under the “Advanced” tab, click on “Environment Variables”
3) From there the “Environment Variables” screen comes up. Look at the “Path” in the “System variables” – if you’re having the issues above – like I was – the “value” of the “Path” is a REALLY long string – and most likely in excess of 2048. Many apps that get installed apparently don’t know of the 2048 rule – and just keep concatenating to the end of the string… sigh…
4) Copy that value out to Notepad ( or better yet Notepad++ – if you don’t have it, get it – awesome free program ). My original value was 2190 characters long ( breaking the 2048 rule ) – and looked like this…
C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;;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)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Common Files\Lenovo;C:\Program Files (x86)\Common Files\Ulead Systems\MPEG;C:\Program Files (x86)\Windows Live\Shared;C:\SWTOOLS\ReadyApps;C:\Program Files (x86)\Symantec\VIP Access Client\;C:\Program Files (x86)\Common Files\Lenovo;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Perforce;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Lenovo\Access Connections\;C:\Program Files (x86)\Perforce;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files\Microsoft\Web Platform Installer\
5) How to fix this without just removing some paths? What to do? Well, you can take advantage of the System Variables and add your own – just click on “New” and you enter, for example, “PF86” with a value of “C:\Program Files (x86)” – nice…
6) Here is the list ones that I came up with after doing a little sorting and looking for common strings to replace – emphasis on keeping the paths short but readable:
- “PF86” == “C:\Program Files (x86)”
- “PF64” == “C:\Program Files”
- “CF” == “\Common Files”
- “IntelE” == “\Intel\Intel(R) Management Engine Components”
- “SQL110” == “\Microsoft SQL Server\110”
- “SQL100” == “\Microsoft SQL Server\100”
- “SQL90” == “\Microsoft SQL Server\90”
- “SQL80” == “\Microsoft SQL Server\80”
7) Now take those values – wrap them in %% – and do a search and replace in the “Path” value.
8) Add more depending on what’s in your path – but just these took me from 2190 to 1371 – Yay under 2048!
%PF64%%CF%\Intel\WirelessCommon\; %PF64%%CF%\Lenovo; %PF64%%CF%\Microsoft Shared\Windows Live; %PF64%%IntelE%\DAL; %PF64%%IntelE%\IPT; %PF64%%SQL100%\DTS\Binn\; %PF64%%SQL100%\Tools\Binn\; %PF64%\Intel\iCLS Client\; %PF64%\Intel\WiFi\bin\; %PF64%SQL110%\Tools\Binn\; %PF64%\Microsoft\Web Platform Installer\ %PF64%\Perforce; %PF64%\ThinkPad\Bluetooth Software\; %PF64%\ThinkPad\Bluetooth Software\syswow64; %PF86%%CF%\Lenovo; %PF86%%CF%\Microsoft Shared\Windows Live; %PF86%%CF%\Ulead Systems\MPEG; %PF86%%IntelE%\DAL; %PF86%%IntelE%\IPT; %PF86%%SQL100%\DTS\Binn\; %PF86%%SQL100%\Tools\Binn\; %PF86%%SQL100%\Tools\Binn\VSShell\Common7\IDE\; %PF86%%SQL80%\Tools\Binn\; %PF86%%SQL90%\DTS\Binn\; %PF86%%SQL90%\Tools\binn\; %PF86%%SQL90%\Tools\Binn\VSShell\Common7\IDE\; %PF86%\Intel\iCLS Client\; %PF86%\Intel\OpenCL SDK\2.0\bin\x64; %PF86%\Intel\OpenCL SDK\2.0\bin\x86; %PF86%\Lenovo\Access Connections\; %PF86%\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\; %PF86%\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\; %PF86%\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\; %PF86%\Perforce; %PF86%\Symantec\VIP Access Client\; %PF86%\Windows Kits\8.0\Windows Performance Toolkit\; %PF86%\Windows Live\Shared; %SystemRoot%; %SystemRoot%\system32; %SystemRoot%\System32\Wbem; %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\; C:\SWTOOLS\ReadyApps;
As always – if anyone finds a better way to do this – always looking to improve – please send your ideas / solutions to me. 🙂
Good coding!
…Lance Larsen