Restarting windows services with action script

I am trying to restart services on endpoint clients by using the following script

waithidden cmd.exe /c net stop
waithidden cmd.exe /c net start

but it fails time, my conclusion is that that there needs to be a pause between the stop and start, as when i run the action separately it works fine but not when i am trying to do them in the same task in BigFix…and i have tried to do it with separate actions on the same task

appreciate any help out there

Thanks in advance

Or maybe there needs to be a service name on your “net stop” and “net start” commands?

forgot to add at end of each line so it should have been posted with

waithidden cmd.exe /c net stop
waithidden cmd.exe /c net start

Sorry, are you adding a service at the end of the line? Taken literally, your command gives me:


waithidden cmd.exe /c net stop <service name>
waithidden cmd.exe /c net start <service name>

not sure why service name gets removed eachtime i post it
example below

waithidden cmd.exe /c net stop AudioSrv
waithidden cmd.exe /c net start AudioSrv

You shouldn’t need to use artificial pauses when using waithidden, as the CMD executable itself won’t exit until the command it is processing is done. That being said, I would personally just use powershell commands for this instead of the net commands.

For example:

waithidden powershell.exe restart-service audiosrv

Alternatively, if you’re set on using net commands, you can do this in one command;

waithidden cmd.exe /c net stop audiosrv && net start audiosrv

Using the && operator means that the second command will only run if the first returned an exit code of zero, ensuring that the start command only runs if the stop command worked.

Alternatively, you can add some logic to your action script to figure out what is happening on the endpoint.

waithidden cmd.exe /c net stop audiosrv
if {exists services “audiosrv” whose (state of it = “Stopped”}
waithidden cmd.exe /c net start audiosrv

The results of the action would show in the local client logs, and would allow you to troubleshoot this a little further.

You have to usethe “code” tag, else the forum presents <> as an HTML markup tag

1 Like

so i tried a new action with the following

waithidden powershell.exe start-service audiosrv

and although it worked fine ie the service stopped… BigFix console returned the action with status failed

also i had also already tried using && to no avail
example - waithidden cmd.exe /c net stop audiosrv && net start audiosrv

also tried with code :-
waithidden cmd.exe /c net stop audiosrv
if {exists services “audiosrv” whose (state of it = “Stopped”}
waithidden cmd.exe /c net start audiosrv

and although it works BigFix again returns the action as failed

What is your fixlet relevance?

waithidden cmd.exe /c net stop audiosrv
if {exists services “audiosrv” whose (state of it = “Stopped”}
waithidden cmd.exe /c net start audiosrv

That’s the action script; I’m asking what your relevance is.

Every fixlet needs a relevance statement in order for clients to determine if they are applicable for the fixlet or not. Each fixlet also needs success criteria, which by default is “… the applicability relevance evaluates to false” for fixlets.

If you don’t have a relevance statement, meaning the fixlet is relevant for all systems (i.e. “True”) and your success criteria is default, all actions you take against that fixlet will fail, because after your action runs the relevance statement is still “True”.

You can set a custom success criteria of “… all lines of the action script have completed successfully”, which if you use the default relevance statement of “True” will cause the action to report Completed as long as all your actionscript commands ran.

I would recommend checking the client logs on the client you are running this action on to determine what the actual action results are.

It’s important to distinguish between “BigFix action result”, as reported in the console, and the actual result of the commands you are running. For example, calling waithidden cmd.exe /c will very often just return exit code 0, because regardless of what command you called from CMD BigFix just sees that CMD started and exited.

Consider whether you need a Fixlet or a Task for your action:

  • When a Fixlet finishes it’s action script, it checks the relevance to make sure it has gone from true, the Fixlet is relevant, to false, whatever was broken is now fixed, and reports back Fixed when it is done.

  • When a task finishes its action script, it does not check the relevance again. If all the lines in the action script completed then the client considers that action successful and reports back Complete. For this reason, as a best practice, you are suggested to set success criteria for the action run by the task to ensure that the task run and that it was successful.

1 Like

You can also just change the success criteria.