Support
10-17-2002, 03:58 PM
<HTML><HEAD><TITLE>HOWTO: Limit the Number of Times an Install can be Run</TITLE></HEAD><BODY><h3>HOWTO: Limit the Number of Times an Install can be Run</h3><b>Document ID: IR02029</b><hr>The information in this article applies to:<ul><li>Setup Factory 6.0</li><li>Setup Factory 5.0</li></ul><hr><h3>SUMMARY</h3><p>This article explains how to limit the number of times an install can be run using Setup Factory 6.0.</p><h3>DISCUSSION</h3><p><b>Note: </b>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.</p><p>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.</p><p><b>Tip: </b>Storing the information in more than one location on a user's system will help prevent tampering.</p><p>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.</p><p>The first action to use is the <b>Read from Registry</b> 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.</p><pre><code><b>Variable name:</b> %InstallCount%
<br><b>Default value:</b> 0
<br><b>Main key:</b> HKEY_CURRENT_USER
<br><b>Sub key:</b> Software\My Company\The Product
<br><b>Value name:</b> InstallCount
<br><b>Set variable to TRUE if Sub Key exists:</b> Unchecked
<br><b>Auto-expand if value is of type REG_EXPAND_SZ:</b> Unchecked</code></pre><p>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 <b>Assign Value</b> action:</p><pre><code><b>Variable name:</b> %InstallCount%
<br><b>Value:</b> %InstallCount% + 1
<br><b>Evaluate value as expression:</b> Checked</code></pre><p>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 <b>Modify Registry</b> action:</p><pre><code><b>Registry Action:</b> Set Value
<br><b>Main Key:</b> HKEY_CURRENT_USER
<br><b>Sub Key:</b> Software\My Company\The Product
<br><b>Value name:</b> InstallCount
<br><b>Value type:</b> REG_SZ
<br><b>Value data:</b> %InstallCount%</code></pre><p>Now that we have set up the Registry value properly and have the current number of installs stored in %InstallCount% we will add an <b>Abort Install</b> screen to the top of the <b>Before Installing</b> list on the <i>Screens</i> dialog.</p><p>The <b>Abort Install</b> 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 <b>Screen Condition</b> to the <b>Abort Install</b> screen. In this example we will set the install limit to 10.</p><p>To set up the screen condition, first double-click on the <b>Abort Install</b> screen in the <i>Screens</i> dialog to view the screen's properties. At the bottom of the Settings tab you will find the <b>Screen Condition</b> field. The condition that we need to add to the screen is:</p><pre><code>(%InstallCount% > 10)</code></pre><p><b>Note: </b> If there are any other conditions on this screen you can AND the new condition with it. (i.e. (%SysLanguage% = 9) AND (%InstallCount% >10)</p><p>This condition basically says: "Show this screen if %InstallCount% is greater than ten". This will cause the <b>Abort Install</b> screen to be displayed if the user tries to run the install more than ten times. The <b>Abort Install</b> screen's built-in actions will take care of aborting the install for you. The only thing left to do is to edit the <b>Screen text</b> on the <b>Abort Install</b> screen to tell the user why the install is being aborted.</p><h3>MORE INFORMATION</h3><p>For more information please see the following topics in the Setup Factory 6.0 Help:</p><li><b>Command Reference | Actions | Individual Actions | Assign Value</b></li><li><b>Command Reference | Actions | Individual Actions | Read from Registry</b></li><li><b>Command Reference | Actions | Individual Actions | Modify Registry</b></li><li><b>Command Reference | Screens | Individual Screens | Abort Install</b></li><li><b>Command Reference | Design Environment | Dialogs | Screens | Screens dialog</b></li><p>KEYWORDS: Setup Factory 6.0, Setup Factory 5.0, Install Limit, Limit number of installs</p><hr><FONT SIZE=1>Last reviewed: February 20, 2003
<br>Copyright © 2003 <A HREF="http://www.indigorose.com" target="blank">Indigo Rose Corporation</a>. All rights reserved.
<br></FONT></BODY></HTML>
<br><b>Default value:</b> 0
<br><b>Main key:</b> HKEY_CURRENT_USER
<br><b>Sub key:</b> Software\My Company\The Product
<br><b>Value name:</b> InstallCount
<br><b>Set variable to TRUE if Sub Key exists:</b> Unchecked
<br><b>Auto-expand if value is of type REG_EXPAND_SZ:</b> Unchecked</code></pre><p>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 <b>Assign Value</b> action:</p><pre><code><b>Variable name:</b> %InstallCount%
<br><b>Value:</b> %InstallCount% + 1
<br><b>Evaluate value as expression:</b> Checked</code></pre><p>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 <b>Modify Registry</b> action:</p><pre><code><b>Registry Action:</b> Set Value
<br><b>Main Key:</b> HKEY_CURRENT_USER
<br><b>Sub Key:</b> Software\My Company\The Product
<br><b>Value name:</b> InstallCount
<br><b>Value type:</b> REG_SZ
<br><b>Value data:</b> %InstallCount%</code></pre><p>Now that we have set up the Registry value properly and have the current number of installs stored in %InstallCount% we will add an <b>Abort Install</b> screen to the top of the <b>Before Installing</b> list on the <i>Screens</i> dialog.</p><p>The <b>Abort Install</b> 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 <b>Screen Condition</b> to the <b>Abort Install</b> screen. In this example we will set the install limit to 10.</p><p>To set up the screen condition, first double-click on the <b>Abort Install</b> screen in the <i>Screens</i> dialog to view the screen's properties. At the bottom of the Settings tab you will find the <b>Screen Condition</b> field. The condition that we need to add to the screen is:</p><pre><code>(%InstallCount% > 10)</code></pre><p><b>Note: </b> If there are any other conditions on this screen you can AND the new condition with it. (i.e. (%SysLanguage% = 9) AND (%InstallCount% >10)</p><p>This condition basically says: "Show this screen if %InstallCount% is greater than ten". This will cause the <b>Abort Install</b> screen to be displayed if the user tries to run the install more than ten times. The <b>Abort Install</b> screen's built-in actions will take care of aborting the install for you. The only thing left to do is to edit the <b>Screen text</b> on the <b>Abort Install</b> screen to tell the user why the install is being aborted.</p><h3>MORE INFORMATION</h3><p>For more information please see the following topics in the Setup Factory 6.0 Help:</p><li><b>Command Reference | Actions | Individual Actions | Assign Value</b></li><li><b>Command Reference | Actions | Individual Actions | Read from Registry</b></li><li><b>Command Reference | Actions | Individual Actions | Modify Registry</b></li><li><b>Command Reference | Screens | Individual Screens | Abort Install</b></li><li><b>Command Reference | Design Environment | Dialogs | Screens | Screens dialog</b></li><p>KEYWORDS: Setup Factory 6.0, Setup Factory 5.0, Install Limit, Limit number of installs</p><hr><FONT SIZE=1>Last reviewed: February 20, 2003
<br>Copyright © 2003 <A HREF="http://www.indigorose.com" target="blank">Indigo Rose Corporation</a>. All rights reserved.
<br></FONT></BODY></HTML>