【发布时间】:2016-11-21 21:30:21
【问题描述】:
我正在尝试使用服务控制器将我的批处理文件 (run.bat) 作为 Windows 服务运行
这是我用来创建服务的命令
sc \\myservername create myservicename binPath="C:\Program Files\Directories to use\ANI\run.bat" start=auto
[SC] CreateService SUCCESS
当我运行我的服务时:
sc start ANIService
[SC] StartService Failed 1053:
The service did not respond to the start or control request in the timely fashion
【问题讨论】:
-
如果您将
"C:\Program Files\Directories to use\ANI\run.bat"替换为只打印echo %1的批处理文件,您会得到同样的错误吗?如果没有,您的问题出在"C:\Program Files\Directories to use\ANI\run.bat"。 -
@LinuxDisciple:不,整个想法都是错误的。服务是实现特定接口的可执行文件,您不能只告诉操作系统批处理文件是服务并期望它工作。 (批处理文件可能会运行,也可能不会运行,但由于它不调用 StartServiceCtrlDispatcher,因此无论哪种方式,您仍然会收到“没有响应”错误。)
标签: batch-file windows-services servicecontroller