How to detect whether or not Visual Studio 2008 SP1 is installed on a system
I am trying to install an application that requires Visual Studio 2008 SP1 before it can successfully install. How can I detect the presence of Visual Studio 2008 SP1?
There is not an officially documented way of detecting VS 2008 SP1. There are some registry keys that store service pack level values, but those keys have proven unreliable in scenarios where more than one edition of Visual Studio is installed on the system, so I would not recommend relying on them because they can give false results in some cases.
The most reliable way I’ve seen to detect Visual Studio 2008 service pack level is to do the following:
- Look up the VS 2008 install location from the registry
- Build a full path to devenv.exe using the install location found in the registry
- Check the file version to make sure it is greater than or equal to 9.0.30729.1 (the VS 2008 SP1 version number)
If you are using WiX v3.0 to build an MSI-based installer that will check for VS 2008 SP1, here is a fragment that will accomplish this:
<Property Id="VS90_SP1" Secure="yes">
<RegistrySearch Id="VS90DevEnvDirectorySearch" Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VS" Name="EnvironmentDirectory" Type="raw">
<FileSearch Id="VS90DevEnvFileVersionSearch" Name="devenv.exe" MinVersion="9.0.30729.1"/>
The above property ships in WiX v3.0 in the WixVSExtension, so you could reference it directly from there in your setup authoring instead of redefining it yourself too. You can find more information about how to do this in the WiX 3.0 WixVSExtension documentation.
A note about VS 2008 Express Editions
If you need to detect SP1 for one of the VS 2008 Express Editions, you can use similar logic to what is described above. Instead of checking the file version of devenv.exe, you will need to check the file version for the Express Edition IDE file – vbexpress.exe, vcexpress.exe, vcsexpress.exe or vwdexpress.exe.
You can look up the locations of the VS 2008 Express Edition IDE files by using the following logic:
Look up the root installation directory for all editions of VS 2008 from the following registry key/value:
For a default install, this registry value will be set to C:\Program Files\Microsoft Visual Studio 9.0\
Append the sub-folders named Common7 and IDE to build a path that looks like C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\
Append the name of the Express Edition IDE file you want to check the version for – vbexpress.exe, vcexpress.exe, vcsexpress.exe or vwdexpress.exe.
WiX v3.0 also includes the following pre-defined detection properties for SP1 for each of the VS 2008 Express Editions:
<update date="4/16/2009"> Added more detail about how to look up the locations of the Visual Studio Express Edition IDE files </update>