I am using SC.exe to configure windows service failure, I would like to run a command and pass in number of fails so far. I can check the 'Append fail to end of command line (/fail=%1%) in service properties, but I don't know how to do that from command line.
So far I have
SC failure "myservice" run/0/run/""/0 reset= 86400 commad="mycommand.exe"
but how to set that value?
Thanks for help.
When specifying the command, just include /fail=%1%
in the arguments. So, your command would read:
SC failure "myservice" run/0/run/""/0 reset= 86400 command="mycommand.exe /fail=%1%"
Note that your parameter will be something like /fail=2
, so you'll need to trim your parameter to get the actual count.
I wasn't sure if you were still looking for how to do this since it's been a few months since you asked, but I thought I'd share since I had the same problem.