使用cmd和start参数安装Windows服务(exe)

我如何安装一个exe文件作为Windows服务与启动参数? 我正在使用sc.exe CREATE但无法find如何添加启动参数。

我也尝试使用nssm,但无法find如何设置启动参数。

一切都必须使用命令提示符完成

我目前正在尝试使用:

 sc CREATE test binPath= "\"C:\a.exe\" --run -c \"C:\a.config" 

但试图运行时,我得到: The service did not respond to the start or control request in a timely fashion.

并不是所有的exe文件都可以作为服务运行。 这不像一个自动运行。 例如CALC.EXE:

 C:\WINDOWS\system32>sc create CALC binpath= "%WINDIR%\system32\calc.exe" [SC] CreateService SUCCESS C:\WINDOWS\system32>sc start CALC [SC] StartService FAILED 1053: The service did not respond to the start or control request in a timely fashion.