HOWTO: Limit the Number of Times an Install can be Run
Document ID: IR02029The information in this article applies to:
- Setup Factory 6.0
- Setup Factory 5.0
SUMMARY
This article explains how to limit the number of times an install can be run using Setup Factory 6.0.
DISCUSSION
Note: This article will explain how to limit the number of times an installation can be run on a single system, not the number of times an installation can be run on multiple systems.
In order to limit the number of times an installation can be run, a count of how many times the installation has been run must be kept. The best place to store this information is the Registry, although you could store this information in a text file or INI file located somewhere on the user's system.
Tip: Storing the information in more than one location on a user's system will help prevent tampering.
In order to count the number of times the installation has been run we will use actions. These actions will be placed on the "On Startup" event so that they are the first thing to occur during the installation.
The first action to use is the Read from Registry action. This action will be used to read the number of times that the install has already been run on the user's system. We will set the default value to zero in case this is the first time that the user has run the installation.
Variable name: %InstallCount%
Default value: 0
Main key: HKEY_CURRENT_USER
Sub key: Software\My Company\The Product
Value name: InstallCount
Set variable to TRUE if Sub Key exists: Unchecked
Auto-expand if value is of type REG_EXPAND_SZ: Unchecked
Now we will increment the value that we read from the Registry (%InstallCount%) because the user is running the install again. To do this we will use an Assign Value action:
Variable name: %InstallCount%
Value: %InstallCount% + 1
Evaluate value as expression: Checked
We now have the number of times that the user has run the installation including the current run. The next step is to record this value in the Registry, so that we can read it when the install is launched again. To do this we will use a Modify Registry action:
Registry Action: Set Value
Main Key: HKEY_CURRENT_USER
Sub Key: Software\My Company\The Product
Value name: InstallCount
Value type: REG_SZ
Value data: %InstallCount%
Now that we have set up the Registry value properly and have the current number of installs stored in %InstallCount% we will add an Abort Install screen to the top of the Before Installing list on the Screens dialog.
The Abort Install screen will be displayed if the user has tried to run the installation more times than they are allowed. To accomplish this we will need to add a Screen Condition to the Abort Install screen. In this example we will set the install limit to 10.
To set up the screen condition, first double-click on the Abort Install screen in the Screens dialog to view the screen's properties. At the bottom of the Settings tab you will find the Screen Condition field. The condition that we need to add to the screen is:
(%InstallCount% > 10)
Note: If there are any other conditions on this screen you can AND the new condition with it. (i.e. (%SysLanguage% = 9) AND (%InstallCount% >10)
This condition basically says: "Show this screen if %InstallCount% is greater than ten". This will cause the Abort Install screen to be displayed if the user tries to run the install more than ten times. The Abort Install screen's built-in actions will take care of aborting the install for you. The only thing left to do is to edit the Screen text on the Abort Install screen to tell the user why the install is being aborted.
MORE INFORMATION
For more information please see the following topics in the Setup Factory 6.0 Help:
KEYWORDS: Setup Factory 6.0, Setup Factory 5.0, Install Limit, Limit number of installs
Last reviewed: February 20, 2003
Copyright © 2003 Indigo Rose Corporation. All rights reserved.