PowerShell VsVars32 – 64-bit style
I ran across this post which is a frickin’ must for PowerShell and Visual Studio integration. Being very excited about this I ended up trying it out right away and ran across a problem. Digging deeper into the VsVars32 function, it became evident that things bonked because the registry path to Visual Studio was not all there:
1> $theVSKey = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\VisualStudio\9.0
2> $theVSKey.InstallDir
This yields nothing at all as $theVSKey is empty. What the crap is going on here?
Well it ends up being a problem related to running on a 64-bit machine. We need to remember that when in 64-bit mode, applications like Visual Studio are really 32-bit and run in the WoW64 mode. In WoW64 there is a separate section of the registry dedicated to 32-bit apps (settings for Visual Studio live here).
What to do now? This is why PowerShell installs the x86 version of itself along side the 64-bit version. This was the first time that I realized the need for the x86 version. At first I thought it was for those peeps that just couldn’t let go to 32-bit land. I guess not.
Ahhhh… all better now.
-
If you enjoyed reading this little piece, please feel free to subscribe to future ones via rss.

Just a word of caution.. the x86 version of PowerShell will have it’s own execution policy, but they share the same shell profile script.