I am updating an installer for a product that provides multiple applications
and want to change it so that it creates shortcuts only for applications that
have a valid licence.
The basic approach is to define each shortcut in a separate component, to set a
condition on the component based on the value of a property and to execute a
custom action to set an appropriate value for the property based on the licence
before the shortcuts are created.
If I set different values when defining the properties, I can see the correct
shortcuts get created. However, any changes to properties made by the custom
action have no effect.
Within the Product element
- define the applications for which we may wish to create shortcuts
<?define shortcuts=manage;translate;LAMPS2?>
- define a property for each application
<?foreach _cut in $(var.shortcuts)?>
<Property Id="$(var._cut)" Value="0" />
<?endforeach?>
- declare the custom action
<CustomAction Id="CheckApplicationLicence"
BinaryKey="CheckLicence.vbs"
Return="ignore"
VBScriptCall="CheckLicence" />
<Binary Id="CheckLicence.vbs"
SourceFile="$(var.goth_product_root)\config\CheckLicence.vbs" />
- arrange for it to be invoked on install
<InstallExecuteSequence>
<Custom Action="CheckApplicationLicence"
After="InstallFiles">NOT (REMOVE = "ALL")
</Custom>
</InstallExecuteSequence>
- create the desktop shortcuts
<Property Id="INSTALL_DESKTOP_SHORTCUTS" Value="1"/>
<DirectoryRef Id="TARGETDIR">
<Directory Id="DesktopFolder">
<?foreach _cut in $(var.shortcuts)?>
<Component Id = "C_DesktopShortCut.$(var._cut)" Guid="*">
<Condition>
INSTALL_DESKTOP_SHORTCUTS AND $(var._cut) = 1
</Condition>
<?define _prefix="Desktop"?>
<?include $(var._cut)_shortcut.wxi?>
<?undef _prefix?>
<RegistryValue Root="HKCU"
Key="Software\1Spatial\Developer\Installed"
Name="DesktopShortcuts.$(var._cut)"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
<?endforeach?>
</Directory>
</DirectoryRef>
The custom action VBScript is:
Option Explicit
Function CheckLicence()
On error resume next
MsgBox("CheckLicence: " + Session.Property("LAMPS2"))
Session.Property("LAMPS2") = "1"
Session.Property("translate") = "1"
MsgBox("CheckLicence: " + Session.Property("LAMPS2"))
End Function
I see both message boxes pop up, showing that the property has been modified.
In the log file, it appears this has been executed before the shortcuts:
InstallFiles: File: Copying new files, Directory: , Size:
Action ended 11:12:25: InstallFiles. Return value 1.
Action 11:12:25: CheckApplicationLicence.
Action start 11:12:25: CheckApplicationLicence.
Action ended 11:12:29: CheckApplicationLicence. Return value 1.
Action 11:12:29: CreateShortcuts. Creating shortcuts
Action start 11:12:29: CreateShortcuts.
CreateShortcuts: Shortcut: Creating shortcuts
Action ended 11:12:29: CreateShortcuts. Return value 1.
Action 11:12:29: WriteRegistryValues. Writing system registry values
If I start with all the properties having a value of 0 and set them to 1 in the
custom action, no shortcuts are created. If I start with a value of 1 and set
them to 0 in the custom action, all the shortcuts are created.
I presume I have made some sort of simple mistake, but I can't see what it is.
Help much appreciated.
I am using the final (July) release of WiX 3 on Windows XP SP2 32-bit.
David
--
David Allen,
Telephone: +44 (0)1223 420 414
1Spatial Group Limited; Registered in England No. 4785688 VAT Reg. No.
816329821; Registered Office: Cavendish House; 6 Cambridge Business Park;
Cambridge; CB4 0WZ; United Kingdom
http://www.1spatial.com/
1Spatial: unlocking data, empowering business
Making geospatial data current, accessible, easily shared and trusted
www.1spatial.com
1Spatial Group Limited; Registered in England No. 4785688 VAT Reg. No.
816329821; Registered Office: Tennyson House; Cambridge Business Park;
Cambridge; CB4 0WZ; United Kingdom
IMPORTANT NOTICE
This e-mail and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you have received this e-mail in error please notify the sender immediately and
delete this e-mail from your system. Please note that any views or opinions
presented in this e-mail are solely those of the author and do not necessarily
represent those of 1Spatial Group Limited, its subsidiaries or associated
companies, except where the author specifically states them to be the views of
1Spatial Group Limited, its subsidiaries or associated companies.
1Spatial Group Limited, its subsidiaries and associated companies will not be
held liable for any legally binding obligations that are not the subject of an
official 1Spatial purchase order or as part of a contract signed by a director
of one of the aforementioned companies.
Although the company has taken reasonable precautions to ensure no viruses are
present in this email, the company cannot accept responsibility for any loss or
damage arising from the use of this email or attachments. You should understand
and accept that, when communicating with us by e-mail, it is not a totally
secure communications medium.
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users