1

I'm having a few issues writing a script to modify the recovery options for a remote service - i.e. add a executable to run on error.

It will have one command line argument

sc %machinename% failure Bla.ServiceName command= "\"E:\Program Files\App\SendEmail.bat" {0}

I've looked at this question, but I can't seem to get it to work as I'd expect.

Anybody have any pointers - similarly if this is easier in C#/PowerShell I'd be happy to consider looking at those options.

Just had another try based on suggestions - the below works but I'd like to remove the "-" if possible. If I do I get an invalid option from the command prompt.

 sc %machinename% failure Service command= "\"E:\Program Files\App\Monitoring\SendEmail.bat\" "Service-is-down-on-env""

Edit...

It seems I didn't test the obvious adding a slash at the end. For those who are wanting to do something similar it should be:

 sc %machinename% failure Service command= "\"E:\Program Files\App\Monitoring\SendEmail.bat\" Service is down on env"

Thanks guys, I knew it might provoke some thought if I wrote it down!

One thing I did notice I can't do is make the message appear as one command line argument - is there something I'm missing there?

Community
  • 1
  • 1
Jamie
  • 876
  • 1
  • 10
  • 28
  • Was the remote service originally installed using 'srvany.exe' by any chance? – Ci3 May 04 '15 at 02:16
  • 2
    Sure a typo but you forget \" -> "\"E:\Program Files\App\SendEmail.bat\"" – JPBlanc May 04 '15 at 04:38
  • 1
    "Can't get it to work" is an insufficient problem description. What result do you get, and how does it differ from the result you were expecting? – Ansgar Wiechers May 04 '15 at 07:06
  • Sorry, you are right - it wasn't a good explanation. It was at midnight my time! I'll update the question. – Jamie May 04 '15 at 14:10

0 Answers0