Parameters and IF/ELSE statement

(imported topic written by npeters91)

Is there a way to control being prompted for parameters when deploying an action?

An example of a script I am working with is:

action parameter query “servicename” with description “Please enter the name of the service to be modified”

action parameter query “actionexe” with description “Please enter an action to take; ie. START | STOP | CONFIG”

If {parameter “actionexe” of action = “CONFIG”}

action parameter query “cfgact” with description "Please enter the config option to take; ie. Start= | DisplayName= "

action parameter query “strstp” with description “If Configuring, would you also like to start or stop the action? Enter START | STOP (Optional)”

dos sc {parameter “actionexe” of action} {parameter “servicename” of action} {parameter “cfgact” of action}


dos sc {parameter “actionexe” of action} {parameter “servicename” of action}


The preference is that only the parameters “cfgact” and “strstp” are prompted for values only if the parameter “actionexe”=“CONFIG” otherwise, I don’t want to be prompted. I’m looking to build a dynamicly prompted deployment of an action based on input.




(imported comment written by BenKus)

Hey Nathan,

Remember that the actions run on the agents and so the way you have written it won’t work… There isn’t any good way to conditionally be prompted in an action like this…

You basically have a few options:

  1. Put all the action parameters at the beginning and then conditionally pick amongst them (e.g., “Enter start/stop for the service (or leave blank if not applicable)” ).

  2. Make different actions for the different things you want to do (e.g., “Click here to configure the service”, “Click here to start the service”, etc.)

  3. Or… you could make yourself a custom wizard that would allow you to enter the the different options and it would dynamically generate the action… But this is probably more effort than it is worth for your task and I think probably #2 is your best bet.