The problem has to do with the scope of properties used by the installer. If you want the user to be able to pass the installer a property which is available during the execution phase of the installation, you have to make that property public. It's very easy to make a property public, you just have to write it ALLCAPS. In your case you have to transform ADXLoaderPrivileges
into ADXLOADERPRIVILEGES
.
Your second problem can be solved rather simply as well. Have a look at the installer database after you have compiled your project with a suitable programme such as orca or instedit. Inspect the InstallUISequence
and the InstallExecuteSequence
tables. Here you can see all standard and custom actions. The order in which each action is executed is determined by the entry in the Sequence
column. You might have guessed it already: The entry in the Condition
column decides if the action gets executed at all based on the condition listed here.
To specify a condition for a CustomAction use the following reference:
- Determine the condition you want to evaluate, in your case it's ADXLOADERPRIVILEGES
- Write your CustomAction
- Insert your CustomAction into the installer Database.
You can do this in two different manners: Either create the
CustomAction
element nested under theProduct
element or nest it under aFragment
element. If you nest it under aFragment
you have to add aCustomActionRef
element to yourProduct
element. The last rule only applies if you don't directly Schedule your CustomAction. This is the case, when a CustomAction gets executed by a buttonclick in the UI, for example. - Schedule your CustomAction.
Create
Custom
elements either under theInstallUISequence
or under theInstallExecuteSequence
elements in yourProduct
element. TheAction
attribute of theCustom
element is the name of theCustomAction
specified by theId
attribute in theCustomAction
element. To determine when a CustomAction gets executed use either theSequence
attribute of theCustom
element, which is absolute, or use either of theBefore
orAfter
attributes, in which you specify the name of another Action (standard or custom), which are relative. - Add the Condition to your CustomAction. The
Custom
element can have one child element which is a textual representation of a condition. Either use plain text or embed your text in CDATA tags.
Here is some code in which the concepts above are used:
The CustomAction Fragment
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Binary Id="AlterSqlStringTable.DLL" SourceFile="$(var.AlterSqlStringTable.TargetDir)AlterSqlStringTable.CA.dll" />
<CustomAction Id="AlterSqlStringTable" BinaryKey="AlterSqlStringTable.DLL" DllEntry="AlterSqlStringTable" Execute="immediate" Return="check" />
</Fragment>
</Wix>
The Product with the Custom
element:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="!(loc.Name)" Codepage="1252" Language="!(loc.Lang)" Version="YO.UR.VERS.ION" Manufacturer="!(loc.Manufacturer)" UpgradeCode="PUT-YOUR-GUID-HERE">
...
<InstallExecuteSequence>
<Custom Action="AlterSqlStringTable" Before="InstallFiles"><![CDATA[ADXLOADERPRIVILEGES = "administrator"]]></Custom>
</InstallExecuteSequence>
...
</Product>
</Wix>