Hi ,
I need help as to how I can find the path where Microsoft visual Studio is installed. I need to use that path in my program. What is the function that has to be called to get the path where Microsoft Visual Studio is installed ?
Hi ,
I need help as to how I can find the path where Microsoft visual Studio is installed. I need to use that path in my program. What is the function that has to be called to get the path where Microsoft Visual Studio is installed ?
Is this for an add-in of some sort for Visual Studio?
Because otherwise, you need to be aware that someone running your program may not actually have Visual Studio installed.
If it is installed, you can generally find it at a known location in the registry, such as HKCR/Applications/devenv.exe/shell/edit/command
for VS2008.
Depending on the app, it's probably best to ask the user, but here's some C# code that should do the trick for VS2008.
RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VS");
string vsInstallationPath = regKey.GetValue("ProductDir").ToString();
regKey.Close();
From the registry, HKLM\Software\Microsoft\VisualStudio\9.0\InstallDir for Visual Studio 2008
It is probably possible to find it by searching the registry, but as I wanted a solution for build scripts I have been using environment variables to do this.
N.B. The name of the environment variable to query is version specific.
For VS2005 you can use VS80COMNTOOLS
For VS2008 you can use VS90COMNTOOLS
If you type SET VS90COMNTOOLS at a command prompt you should see: VS90COMNTOOLS=C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\
so go up two folders to get to the root of the install path.