Please provide the action relevance with below specifications

HI All,

I want to create a action statement to start the service after the below check s

could you please help me in this.

  1. Service must be exists by service name or display name.
  2. Service start type must not be disabled.
  3. Service must not be in running state.
  4. Service name passed as parameter not hard coded.

Thanks
Naresh.

Naresh,

What have you tried so far?

Once we know what you’ve tried we can help figure out what is going wrong and help you build this fixlet!

Bill

HI Bill i have tried the below


action parameter query "ServiceName" with description "Please enter the service you would like to start:" With default "<Enter Service Name>"

continue if {exists service whose (service name of it as lowercase = (parameter "ServiceName" of action as lowercase) OR (display name of it as lowercase = (parameter "ServiceName" of action as lowercase)) AND start type of it as lowercase contains "disabled")}
delete __appendfile 
delete netquiet.bat 

appendfile @ECHO OFF 
appendfile start "" /min /b net %1 %2 /y > NUL 2> NUL 
move __appendfile netquiet.bat 

waithidden "{pathname of client folder of site "BESSupport" & "\RunQuiet.exe"}" netquiet.bat start "{parameter "ServiceName" of action}"

delete netquiet.bat

action parameter query "ServiceName" with description "Please enter the service you would like to start:" With default "<Enter Service Name>"

continue if {exists service whose (service name of it as lowercase = (parameter "ServiceName" of action as lowercase) OR (display name of it as lowercase = (parameter "ServiceName" of action as lowercase)) AND start type of it as lowercase contains "disabled")}
delete __appendfile 
delete netquiet.bat 

appendfile @ECHO OFF 
appendfile start "" /min /b net %1 %2 /y > NUL 2> NUL 
move __appendfile netquiet.bat 

waithidden "{pathname of client folder of site "BESSupport" & "\RunQuiet.exe"}" netquiet.bat start "{parameter "ServiceName" of action}"

delete netquiet.bat

action parameter query "ServiceName" with description "Please enter the service you would like to start:" With default "<Enter Service Name>"

continue if {exists service whose (service name of it as lowercase = (parameter "ServiceName" of action as lowercase) OR (display name of it as lowercase = (parameter "ServiceName" of action as lowercase))) AND (start type of it as lowercase does not contain "disabled")}
delete __appendfile 
delete netquiet.bat 

appendfile @ECHO OFF 
appendfile start "" /min /b net %1 %2 /y > NUL 2> NUL 
move __appendfile netquiet.bat 

waithidden "{pathname of client folder of site "BESSupport" & "\RunQuiet.exe"}" netquiet.bat start "{parameter "ServiceName" of action}"

delete netquiet.bat

action parameter query "ServiceName" with description "Please enter the service you would like to start:" With default "<Enter Service Name>"

continue if {exists service whose (service name of it as lowercase = (parameter "ServiceName" of action as lowercase) OR (display name of it as lowercase = (parameter "ServiceName" of action as lowercase))) AND (start type of service whose (service name of it as lowercase = (parameter "ServiceName" of action as lowercase) OR display name of it as lowercase = (parameter "ServiceName" of action as lowercase)) as lowercase does not contain "disabled")}
delete __appendfile 
delete netquiet.bat 

appendfile @ECHO OFF 
appendfile start "" /min /b net %1 %2 /y > NUL 2> NUL 
move __appendfile netquiet.bat 

waithidden "{pathname of client folder of site "BESSupport" & "\RunQuiet.exe"}" netquiet.bat start "{parameter "ServiceName" of action}"

delete netquiet.bat

action parameter query "ServiceName" with description "Please enter the service you would like to start:" With default "<Enter Service Name>"

continue if {exists service whose (service name of it as lowercase = (parameter "ServiceName" of action as lowercase) OR (display name of it as lowercase = (parameter "ServiceName" of action as lowercase)))}
continue if {(start type of service whose (service name of it as lowercase = (parameter "ServiceName" of action as lowercase) OR display name of it as lowercase = (parameter "ServiceName" of action as lowercase)) as lowercase does not contain "disabled")}

delete __appendfile 
delete netquiet.bat 

appendfile @ECHO OFF 
appendfile start "" /min /b net %1 %2 /y > NUL 2> NUL 
move __appendfile netquiet.bat 

waithidden "{pathname of client folder of site "BESSupport" & "\RunQuiet.exe"}" netquiet.bat start "{parameter "ServiceName" of action}"

delete netquiet.bat

Some notes to get you started:

  1. You don’t need netquiet or runquiet.exe
  2. We can remove the Batch script too
  3. Always stick with super simple continue if relevance

Try this (I have not tested this so take a look!):

action parameter query "ServiceName" with description "Please enter the service you would like to start:" With default "<Enter Service Name>"

continue if {exists service (parameter "ServiceName" of action)}
continue if {start type of service (parameter "ServiceName" of action) = "disabled" or state of service (parameter "ServiceName" of action) != "Running"}

wait net start "{parameter "ServiceName" of action}"
wait sc config "{parameter "ServiceName" of action}" start= auto

Thanks a lot i will try this in my infra and i will get back to you with the result.