views:

2149

answers:

6

I know there is a registry key indcating the install directory, but don't remember what it is off-hand.

Currently interested in VS2008 install directory, though it wouldn't hurt to list others for future reference.

+2  A: 

I'm sure there's a registry entry as well but I couldn't easily locate it. There is the VS90COMNTOOLS environment variable that you could use as well.

ZebZiggle
A: 

Environment: Thanks to Zeb and Sam for the VS*COMNTOOLS environment variable suggestion. To get to the IDE in PowerShell:

$vs = Join-Path $env:VS90COMNTOOLS '..\IDE\devenv.exe'


Registry: Looks like the registry location is HKLM\Software\Microsoft\VisualStudio, with version-specific subkeys for each install. In PowerShell:

$vsRegPath = 'HKLM:\Software\Microsoft\VisualStudio\9.0'
$vs = (Get-ItemProperty $vsRegPath).InstallDir + 'devenv.exe'

[Adapted from here]

Emperor XLII
A: 

Aren't there environment settings? I have VCToolkitInstallDir and VS71COMNTOOLS although I'm using VS2003, I don't know if that changed for later versions. Type "set V" at the command line and see if you have them.

Sam Hasler
A: 

Strange, but there doesn't seem to be any values under that key in my registry. I'm running Vista Ultimate 64-bit with VS 2008 SP1.

+1  A: 

Ah, the 64-bit machine part was the issue. Turns out I need to make sure I'm running the PowerShell.exe under the syswow64 directory in order to get the x86 registry keys.

Now that wasn't very fun.

A: 

Use Environment.GetEnvironmentVariable("VS90COMNTOOLS"); also in 64 bit enviroment, it works for me.

peter