PDA

View Full Version : Windows PATH Limits



Jeff Morse
09-19-2014, 09:29 AM
Hi,

I apologize up front because this is not really an IA question, even though I am dealing with it in an IA installer. I searched the web for answers but got conflicting info (at least I thought so). And I haven't received an answer from my MSDN post so I thought I'd give the IA forum a try.

We have an installer that needs to add some directories to the Windows system environment PATH variable. What is the maximum number of characters PATH can contain? Do I need to care? Assuming I have a HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment registry key with PATH value that contains 1500 characters, running setx MYPATH "%PATH%" in a Win7 command prompt warns me the data being saved is truncated to 1024 characters. Yet there is no issue setting that same MYPATH key in the installer using a Set System Environment Variable or Set Windows Registry action. I guess, because we're dealing directly with the registry?

If I do need to worry about the PATH length, how do I handle an embedded environment variable, say %HOME% (C:\my\home\directory) in my custom code? When I determine the length of PATH, do I use HOME's 20-character expanded string or do I use the 6-character string %HOME%?

-Jeff

Jeff Morse
11-11-2014, 10:59 AM
FOr closure reasons: After searching the web and a bunch of testing we decided to go with limits of 1024 for XP/Server 2003 (Windows version < 6) and 2048 for Vista/Server2088 + (version >= 6).