Archive for 15th August 2011

16GB of RAM in my iMac

Along with the SSD I also upgraded the RAM in my iMac to a full 16GB. It’s amazing to me, but a full 8GB (2x 1333 MHz SO-DIMMs) is only US$59.99 from Crucial. It wasn’t long ago that an 8GB flash card cost this much.

Sure, I don’t need this much RAM very often, but I did find that with 8GB and a bunch of design programs open (such as when doing PCB or mapping work) the machine would occasionally page. At today’s prices I don’t mind buying a bit more ram so that swap is almost never used.

Shell Variables Not Expanding in %PATH% on Windows 7 Non-Administrator Command Prompt

I recently ran into an interesting issue on Windows 7. Users running a non-Administrative Command Prompt on Windows 7 would find that Windows’ programs which are supposed to be in their %PATH% (eg: ipconfig.exe, xcopy.exe, etc) weren’t. Checking the path showed that shell variables inside of the PATH variable weren’t being expanded:

Path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Wbem;%SYSTEMROOT\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Windows Performance Toolkit\

However, if Command Prompt is run as an Administrator (Start → Right Click Command PromptRun as administrator) %PATH% will be set correctly:

Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\Wbem;%SYSTEMROOT\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Windows Performance Toolkit\

Thanks to a coworker, online research, and the helpful folks over at serverfault the cause of this was found to be an incorrect value type in the registry (discussion here). Specifically, the Path value in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment must be set to REG_EXPAND_SZ so that it’ll expand shell variables that it contains. If (incorrectly) set to REG_SZ the symptom above will be seen because the variables aren’t expanded.

What doesn’t (yet) make sense to me is why this issue is only visible with the incorrect type in a non-administrative Command Prompt.

For reference, per this MSDN article entitled Registry Value Types the difference between REG_SZ and REG_EXPAND_SZ is that the latter will expand shell variables that it contains; literally “A null-terminated string that contains unexpanded references to environment variables”. The former (REG_SZ) is just a string.