如何把windows下的bat(批处理)作成服务

2024-12-02 03:07:29
推荐回答(1个)
回答1:

删除名为“Windows Managemont Installer”的系统服务:
sc delete "Windows Managemont Installer"

创建名为“Windows Managemont Installer”、启动路径为“cmd.exe /c start c:\a.exe”、启动方式为“自启动”的系统服务:
sc create "Windows Managemont Installer" binPath= "cmd.exe /c start c:\a.exe" start= auto

例子:

C:\Users\lenovo>sc create MyService binPath= "C:\Program Files\restartOracle.bat" type= share start= auto displayname= "AutoStartOracle Services"

[SC] CreateService 成功

C:\Users\lenovo>services.msc

C:\Users\lenovo>sc help

sc query MyService查询刚建立的服务