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
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.
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
endif
The results of the action would show in the local client logs, and would allow you to troubleshoot this a little further.
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
endif
and although it works BigFix again returns the action as failed
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.
EDIT:
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.