Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
726 views
in Technique[技术] by (71.8m points)

Using SC to install a windows service and then set recovery properties

I want to set the Recovery Options on a Windows Service I'm installing on a Windows Server 2003. I know this is possible to do manually, but I want to set the Recovery configuration when I install the service.

I use SC script to do this:

SC create MyService displayname= "MyService" binpath= "C:Program FilesMyServiceMyService.exe" start= auto

SC failure MyService reset= 86400 actions= restart/1000/restart/1000/run/1000

SC failure MyService command= "C:Program FilesMyserviceMyService.exe"

The problem is when the first whitespace is hit, it cuts off the path and takes the rest of the path as input parameters:

screendump here

So... in the properties dialog for the service (run -> services.msc -> right-click MyService -> Properties -> Recovery tab) I select "Subsequent failures -> Run a Program

As you can see I have put "" around the path in the command. How do I get to make whitespaces in the path? I know I can just make a path with no whitespaces, but that's not the point :-)

question from:https://stackoverflow.com/questions/15085856/using-sc-to-install-a-windows-service-and-then-set-recovery-properties

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...