sonia charan
sonia charan

Reputation: 17

how to check visual c++ 2013 is installed or not in bootstrapper(wix)?

I am trying to install visual c++ 2013 with bootstrapper, so inside the bundle tag i am using following code to install visual c++ 2013 as follows

 <ExePackage Id="VC2013" Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="no" InstallCommand="/q" SourceFile=".\vcredist_x862013.exe"  />

currently it will install always, irrespective of whether it is installed or not, how can i put check for whether it is installed or not?

Upvotes: 0

Views: 411

Answers (1)

Calum MacLeod
Calum MacLeod

Reputation: 443

In your bundle, add the following lines:

<util:RegistrySearch Id="VCRedistTest64" Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{GUID_HERE}" Result="exists" Variable="VCR64Present" Win64="yes"/>
<util:RegistrySearch Id="VCRedistTest32" Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{GUID_HERE}" Result="exists" Variable="VCR32Present" Win64="no"/>

Replace the {GUID_HERE} tags with the correct GUID for Visual C++ 2013. To find this, on a machine with Visual C++ already installer, open your registry and navigate to:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\

In this key there will be several subkeys, where each subkey corresponds to one software package currently installed. Find the key which corresponds to the Visual C++ 2013, and copy the key name, which is the GUID you need to insert into the above code.

Finally, change your Exepackage element to:

<ExePackage Id="VC2013" Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="no" InstallCommand="/q" SourceFile=".\vcredist_x862013.exe"  DetectCondition="(VCR32Present OR VCR64Present)/>

This will allow Windows to detect if Visual C++ is already installed, and will prevent your installer from re-installing it.

Also, add the following to the top level "Wix" tag:

xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"

Upvotes: 3

Related Questions