使用 SC 安装 Windows 服务,然后设置恢复属性 [英] Using SC to install a windows service and then set recovery properties

查看:41
本文介绍了使用 SC 安装 Windows 服务,然后设置恢复属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Windows Server 2003 上安装的 Windows 服务上设置恢复选项.我知道这可以手动完成,但我想在安装服务时设置恢复配置.

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.

我使用 SC 脚本来做到这一点:

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:

所以...在服务的属性对话框中(运行 -> services.msc -> 右键单击​​ MyService -> 属性 -> 恢复选项卡) 我选择 后续故障-> 运行程序

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 :-)

推荐答案

这个语法似乎有效:

sc failure MyService command= ""c:program filesmyservicemyservice.exe""

这篇关于使用 SC 安装 Windows 服务,然后设置恢复属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆