5

I need to create an install file that will check the registry for the version of another software. Currently I'm commenting and un-commenting lines of code for separate installs. How can I turn the below into an conditional?

<!--<Property Id="ACADREG" Value="ACAD-A001:409" /> Autocad 2012--> 
<Property Id="ACADREG" Value="ACAD-A004:409" /> <!--Autocad Arch 2012--> 

I also need to obtain which version that is for later in the install.

    <Property Id="ACADROAMDIR">
    <RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="RoamableRootFolder" />
    </Property>


    <Property Id="ACADDIR">
    <RegistrySearch Id="AcadLocRegistry" Type="raw" Root="HKLM" Key="SOFTWARE\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="AcadLocation" />
    </Property>

Is there a way wiX can set [ACADREG] by reading the registry instead of me setting it like I did above?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Robert
  • 809
  • 3
  • 10
  • 19
  • `` element is used to read information from the registry. Then you can control which components, features, and actions are executed depending on the value of this property. – Alexey Ivanov Jan 24 '12 at 10:19
  • You can read registry for both the versions of software and provide a screen to the user to select one from them... – vinay Jan 31 '12 at 07:04

2 Answers2

1

You can use a Preprocessor condition:

<?define AutocadSku = "ACAD2012" ?>

<?if $(var.AutocadSku) = "ACAD2012" ?>
  <Property Id="ACADREG" Value="ACAD-A001:409" />
<?else?>
  <Property Id="ACADREG" Value="ACAD-A004:409" />
<?endif ?>

Or even better, the best practice is searching for both, so later on you could conditionally check for each property's existence or content:

<Property Id="ACADROAMROOTDIR">
  <RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\R18.2\ACAD-A001:409" Name="RoamableRootFolder" />
</Property>
<Property Id="ACADROAMARCHROOTDIR">
  <RegistrySearch Id="ARCHROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\R18.2\ACAD-A004:409" Name="RoamableRootFolder" />
</Property>
KMoraz
  • 14,004
  • 3
  • 49
  • 82
  • This looks like I would still be creating two separate .msi packages. I'm wanting to create one .msi file that will cater to both versions of AutoCAD. – Robert Jan 23 '12 at 16:45
  • No exactly, but it just forces you to maintain these properties. I think you shouldn't over-complicate it. I've updated my answer according to my understanding of your requirement. – KMoraz Jan 23 '12 at 17:03
  • This really isn't what I was looking for. I've updated my post with what my code looks like. – Robert Jan 23 '12 at 18:58
  • How can I conditionally check for each property's content? – Robert Jan 23 '12 at 20:16
  • It depends... what do you intend to do with `ACADREG`? something like this? http://stackoverflow.com/a/1215855/147211 – KMoraz Jan 23 '12 at 21:29
0

It seems like you want to redefine the property if the AutoCAD Arch 2012 is defined, otherwise use Autocad 2012. I had a similar issue and I used the solution I found on this SO question

<Property Id="ACADREG" Value="ACAD-A001:409" /> <!-- Autocad 2012--> 
<Property Id="ACADREG_ARCH" Value="ACAD-A004:409" /> <!--Autocad Arch 2012--> 


<Property Id="ACADROAMDIR">
<RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="RoamableRootFolder" />
</Property>

<Property Id="ACADROAMDIR_ARCH">
<RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\[ACADVER]\[ACADREG_ARCH]" Name="RoamableRootFolder" />
</Property>

<Property Id="ACADDIR">
<RegistrySearch Id="AcadLocRegistry" Type="raw" Root="HKLM" Key="SOFTWARE\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="AcadLocation" />
</Property>

<Property Id="ACADDIR_ARCH">
<RegistrySearch Id="AcadLocRegistry" Type="raw" Root="HKLM" Key="SOFTWARE\Autodesk\AutoCAD\[ACADVER]\[ACADREG_ARCH]" Name="AcadLocation" />
</Property>

<SetProperty Id="ACADROAMDIR" After="AppSearch" Value="[ACADROAMDIR_ARCH]">
 ACADROAMDIR_ARCH
</SetProperty>

<SetProperty Id="ACADDIR" After="AppSearch" Value="[ACADDIR_ARCH]">
 ACADDIR_ARCH
</SetProperty>

After that, the properties you want will correctly be in ACADDIR and ACADROAMDIR

Community
  • 1
  • 1
Jason Kulatunga
  • 5,814
  • 1
  • 26
  • 50