Microsoft KB Archive/212793

= SMSINST: Increment Variable Operation Does Not Work as Expected =

Article ID: 212793

Article Last Modified on 10/27/2006

-

APPLIES TO


 * Microsoft Systems Management Server 2.0 Service Pack 5

-



This article was previously published under Q212793



SYMPTOMS
When using Set Variable Action with the Increment Operation in a Systems Management Server Installer script, the numeric variable will not increment as expected. It will remain at "1" and might never exit a loop if that value is being evaluated as the loop's conditional.



CAUSE
When writing a script for a loop in which a variable is needed to increment through each iteration of the loop, only the increment operation and the variable should be selected. This will not work properly unless a new value is given to increment. This can be thought of as a typical X = X + 1 type of operation where the first X is the variable and the second X is the new value.



WORKAROUND
To work around this problem, simply set the new value to your variable name surrounded with "%" symbols. The following is an example of such a script: Set Variable COUNTER to

While COUNTER Less Than "10" do Display Message "Counter" Set Variable COUNTER to %COUNTER% End Block Note that %COUNTER% should be defined as the message text in the display message script item. Also, the operation value within "Set Variable COUNTER to %COUNTER%" should be defined as increment.

In this example COUNTER is the variable and %COUNTER% is the new variable inside the Set Variable dialog box.

Additional query words: prodsms smsinst

Keywords: kbprb KB212793

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.