2016-11-21 109 views
0

我試圖使用服務控制器SC StartService失敗1053在運行一個批處理文件作爲服務

這是我用來創建我的服務的命令來運行我的批處理文件(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 
+0

如果用一個只打印'echo%1'的批處理文件替換'「C:\ Program Files \目錄使用\ ANI \ run.bat」'你會得到同樣的錯誤嗎?如果不是,你的問題是''C:\ Program Files \目錄使用\ ANI \ run.bat「'。 – LinuxDisciple

+0

@LinuxDisciple:不,整個想法是錯誤的。服務是一個實現特定接口的可執行文件,你不能僅僅告訴操作系統一個批處理文件是一個服務,並希望它能夠正常工作。 (批處理文件可能運行也可能不運行,但是因爲它不調用StartServiceCtrlDispatcher,所以您仍然會以任何方式得到「沒有響應」錯誤。) –

回答

相關問題