Using Windows Installer Properties to Dynamically Configure a Scheduled Task
InstallShield 2024
Project:
This information applies to the following project types:
You can use a Windows Installer property to specify information such as the account information that should be used to run the file that a scheduled task launches.
At run time, Windows Installer uses MsiFormatRecord to resolve the property value, and it uses that value to configure your scheduled task. This enables you to use data that end users enter in dialogs, or other configuration information that is determined at run time, when your product’s scheduled tasks are created at run time.
Example
The following procedure demonstrates how to let end users specify during installation an account and password that should be used to run the scheduled task. The properties that you specify must be enclosed within square brackets, and the property names must be all uppercase; for example, [MYPROPERTY].
Step 4 of the procedure is slightly different, depending on the project type, since Windows Installer controls the user interface of Basic MSI installations, and the InstallScript engine controls the user interface of InstallScript MSI installations.
To let end users specify account and password information for the scheduled task:
|
1.
|
In the View List under System Configuration, click Scheduled Tasks. |
|
2.
|
In the Scheduled Tasks explorer, select the task that you want to configure. |
|
3.
|
In the Run As setting, enter the following: |
[DOMAINNAME]\[USERNAME]
|
4.
|
In the Password setting, enter the following: |
[PASSWORD]
|
5.
|
Use the properties in a dialog. This part of the procedure depends on which project type you are using. |
|
•
|
For Basic MSI projects: |
|
a.
|
In the View List under User Interface, click Dialogs. |
|
b.
|
In the Dialogs explorer, expand the All Dialogs folder, and click the language under the dialog that should contain Domain Name, User Name, and Password controls. As an alternative, you can add a new dialog. |
|
c.
|
Add an Edit Field control to the dialog, and set its Property property to the following: |
DOMAINNAME
|
d.
|
Repeat step 5c for the USERNAME and PASSWORD properties. |
|
•
|
For InstallScript MSI projects: |
|
a.
|
In the View List under Behavior and Logic, click InstallScript. |
|
b.
|
Find the dialog code in the OnFirstUIBefore event for the dialog that should contain the Domain Name, User Name, and Password controls, and add a call to the Windows Installer API function MsiSetProperty. For example, if you want end users to enter the information in edit boxes on the SdShowDlgEdit3 dialog that you have added to your project, you would add MsiSetProperty calls as shown in the following lines of code: |
Dlg_SdShowDlgEdit3:
nResult = SdShowDlgEdit3
(szTitle, szMsg, szField1, szField2, szField3, svEdit1, svEdit2, svEdit3);
MsiSetProperty (ISMSI_HANDLE, "DOMAINNAME", svEdit1);
MsiSetProperty (ISMSI_HANDLE, "USERNAME", svEdit2);
MsiSetProperty (ISMSI_HANDLE, "PASSWORD", svEdit3);
if (nResult = BACK) goto Dlg_SdWelcome;
See Also
Scheduled Tasks View