这是关于 sc.exe
我想在 Windows 中将我的程序作为服务运行。我可以使用命令提示符来完成
我的程序放在system32文件夹中,所以首先我去system32然后我使用这些命令
c:\windows\system32>sc create demo binpath= "pg.exe" type= own start= auto DisplayName= "autostart"
c:\windows\system32>sc config demo binpath= "cmd.exe /c c:\windows\system32>pg.exe" type= own start= auto DisplayName= "autostart"
Run Code Online (Sandbox Code Playgroud)
执行这些命令后,当我重新启动 PC 时,我的程序开始作为服务运行,这很好。
现在,我想制作一个自动脚本来执行这些命令,但无法理解我是如何做到的。
我试过这个
#include <RunCMD.au3>
$cmd = "sc create demo1 binpath= c:\pg.exe type= own start= auto"
_RunCMD($cmd)
$cmd = "sc config demo1 binpath= "cmd.exe /c c:\pg.exe" type= own start= auto"
_RunCMD($cmd)
Run Code Online (Sandbox Code Playgroud)
第一个命令成功执行,但第二个命令没有。