Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I use msbuild to build some projects and have to invoke msdev.exe (Visual Studio 6) to build older projects. Since there is a need to use the msbuild-project on different computers I have to get the installdirectory of Visual Studio 6 each or something else.

Thanks in advance for any help.
Posted

Please try code below:

C#
/// <summary>
        /// Gets the Visual Studio 2008 installation directory path.
        /// </summary>
        /// <returns>Visual Studio 2008 installation directory path</returns>
        public static string GetVS9InstallDirectory()
        {
            string vsInstallationPath;

            RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VS");
            vsInstallationPath = regKey.GetValue("ProductDir").ToString();
            regKey.Close();

            return vsInstallationPath;
        }


Replace the path with visual studio 6.0
 
Share this answer
 
v2
Comments
Apfelmuuus 8-Mar-11 8:59am    
I replaced it this way: @"SOFTWARE\Microsoft\VisualStudio\6.0\Setup\VS"
But it doesn't work. I do not know the correct key where can I get it?
May I add to Amit Kumar Tiwari solution:
First you need to check if you're running in x86 or x64. This could be achieved by:
System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")
Please note that this only works if the variable isn't manipulated!!

If the architecture is x86 use the subkey
"SOFTWARE\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++"

If the architecture is x86 use the subkey "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++"
 
Share this answer
 
Comments
Wild-Programmer 8-Mar-11 10:03am    
Perfect addition :) Thank you.
Ryan Zahra 8-Mar-11 10:05am    
Cheers :) You still got my 5 as you were spot on!
Apfelmuuus 8-Mar-11 10:18am    
Again I've learned something usefull today^^
All right I got it!

I just changed.

RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VS");            
vsInstallationPath = regKey.GetValue("ProductDir").ToString();


to:

RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio\6.0");
vsInstallationPath = regKey.GetValue("InstallDir").ToString();


Thanks a lot for your help!
 
Share this answer
 
Comments
Wild-Programmer 8-Mar-11 9:51am    
I am glad it worked out for you :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900