<< Click to Display Table of Contents >> Navigation: 3. Script Language > NT Service commands > Service Commands |
MiniRobotLanguage (MRL)
WSC. Wait for Command
Manage NT Services
Intention
This command can be used to manage System Services. You can wait until they are running or stopped. You can even wait for the Starting Mode of a service and much more.
To specify a service you will need to give the "service name". Please see
How to get the proper service name
on which choices you have to specify the service you want to deal with, in a way that it will really work for you, as expected.
Syntax
WSC.P1|P2[|P3][|P4][|P5]
Details of the parameters depend on the used Subcommand, see below.
Parameter Explanation
P1 - Subcommand
' Wait for a specified "running state" of a service
"sta" or "state"
Wait until a service is paused, started or stopped. The command checks if the service
has the "running state" that is specified in P4. For P4, you can specify a numeric value
or a textual parameter like these: !Service Commands
You can specify multiple values if they are separated with "," like this:
WSC.sta|dn:yah|||stop,stop pending
' Examples:
' Wait unlimited time until service is stopped
WSC.sta|dn:yah||stop
' Wait 60 seconds time until service is started
WSC.sta|dn:yah||start
' Check timeout flag
JIT.error
' Wait for a specified "running state group" of a service
"stg" or "state group"
Evaluate, if the "running state" of the service P2 (you must specify the service name)
is equal to the state given in P4. For P4, you can specify a numeric value or a textual
parameter, details see !Service Commands
' Examples:
WSC.stg|dn:yah|||stop
' Wait for any of multiple "running state" of a service
"ans" or "any state"
Evaluate, if the "running state" of the service P2 (you must specify the service name)
is equal to the state given in P4. For P4, you can specify a numeric value or a textual
parameter like these: !Service Commands
' Examples:
' Service may not have any of these states
WSC.ans|dn:yah|!|2,3,4
' Service should have any of these states
WSC.ans|dn:yah||2,3,RUN
' Wait for a specified start mode of a service
"sm" or "start mode"
Evaluate the "Start Mode" of a specified service and compare with a specified
start-Mode P4. P4 can be a number from 2 to 4 or a phrase.
See a list of all numbers, phrases and their meanings here: !Service Commands
' Examples:
WSC.sm|dn:yah|||demand
Further tests:
"run","running"
Wait until Run State is 4 (RUN)
WSC.run|NetLog
' Wait until service is NOT running
WSC.run|yah||!
"stop","stopped"
Test if Run State is 1 (STOP)
WSC.stop|bdsvc
"pau","paused"
Test if Run State is 7 (PAUSE)
WSC.pau|servicename
"dis","disabled","deaktiviert"
Test if Start-Mode is 4 (disabled)
WSC.dis|Logon
"auto","automatisch","autostart"
Test if Start-Mode is 2 (AUTO)
WSC.auto|sn
"manuell","demand","on demand"
Test if Start-Mode is 3 (on demand)
WSC.demand|sn
"pen","pending"
Test if the service Run State is in any
"Pending State". These are any of the states:
"Start pending", "Stop pending", "Continue pending" or
"Pause pending".
WSC.pen|sn
"pen-sta","start pending"
Test if the service is "Start pending" or "Continue pending"
WSC.pen-sta|sn
"pen-sto","stop pending"
Test if the service is "Stop pending" or "Pause pending"
WSC.pen-sto|sn
P2 - Service-Name
P3 - Computer-Name or empty. In that case the local computer is used.
P4 - (optional) Waiting time in seconds, if prefixed with a "!", the command will wait for NOT the given condition.
' Wait 10 seconds for service to become disabled
WSC.sm|yah||10|dis
' Wait 10 seconds for service to NOT be disabled
WSC.sm|yah||!10|dis
P5 - (optional) Meaning of P4 depends on used Subcommand.
What happens in case of an error?
If the specified service is not found, the Error-Message "Error: No such service." is been placed on TOS and the condition is evaluated to FALSE..
In case there are other errors during the processing of the command, the error-message is been placed on TOS and the condition is evaluated to FALSE.
The error-message will always be prefixed with an "Error: " to indicate that it is an error from the services-engine.
Here is an example for such an error-message:
"Error: The requested access to the services database was denied."
If an timeout occurs, the timeout flag will be set and the script will continue its operation.
You can check the timeout-flag with the ITO./NTO. or the JIT./JNT. commands, or use the #tio# System-Variable.
Example
'**********************************
' WSC.
'**********************************
WSC.sm|dn:yah|30|demand
ITO.
DBP.Timeout occured
ELS.
DBP.things happened in time
EIF.
' Display Error if we got one
DBP.$$000
ENR.END.
'**********************************
Remarks
-
Limitations:
-
See also:
• ISI. / NSI. - If Service Installed