Windows Installer Editor Reference
450
Using MSI Script
The sample WiseScript looks like this (the script lines are numbered for clarity):
1. Get Windows Installer Property SERIALNUM into SERIALNUMBER
2. Get Windows Installer Property INSTALLDIR into MAINDIR
3. Set Variable EDITION to LEFT$(SERIALNUMBER,1)
4. Check free disk space
5. If EDITION Equals "R" then
6.
Install File c:\Development\Source\RLicense.exe to %MAINDIR%\RLicense.exe
7. Else
8.
If EDITION Equals "S" then
9.
Install File c:\Development\Source\SLicense.exe to %MAINDIR%\SLicense.exe
10.
Else
11.
If EDITION Equals "" then
12.
Display Message "Invalid serial number"
13.
End
14.
End
15. End
To ensure the license file is uninstalled when the application is uninstalled, add actions
to the script to handle the uninstall.
See
Uninstalling Changes Made by a WiseScript
.
Uninstalling Changes Made by a WiseScript
You can use the Run WiseScript custom actions to make changes to the destination
computer when the script is run from your .MSI. (Example: You can use the Install
File(s) script action to add files or you can use the Edit Registry script action to add, edit,
or delete keys or values in the registry.) However, the Windows Installer installation
does not recognize any changes the WiseScript makes to the system and therefore will
not uninstall any of these changes during uninstall of the main Windows Installer
installation.
To solve this problem, do the following:
z
In the WiseScript, include steps to install an installation log and Unwise32.exe.
z
In the .MSI, during an uninstall, use a custom action to call the Unwise32.exe that is
in the WiseScript.
Example: You have an .MSI named Core and a WiseScript named CorePlus. CorePlus
includes an Install File(s) script action that installs a file named A.dll. You want to make
sure that A.dll gets uninstalled when Core is uninstalled.
In the Core .MSI, do the following:
1. Select MSI Script and click the Execute Immediate tab.
2. Scroll down and click directly below the RemoveExistingProducts action.
3. Add an If Statement with a value of NOT Installed.
This condition causes it to run only during initial installation of Core.