:: 如何将某个程序加入服务中
:: 用SC命令操作服务 :: 1、如果服务MyTelnet还没有安装则执行DOS命令安装该服务 :: 2、如果服务MyTelnet还没启动,则用DOS命令启动该服务
:: 假设服务MyTelnet对应C:\Windows\System32\tlntsvr.exe :: SC CREATE MyTelnet binPath= C:\Windows\System32\tlntsvr.exe type= own start= auto :: 等号[=]后面必须有一个空格
SET serviceName=MyTelnet
SET servicePath=%SystemRoot%\system32\tlntsvr.exe
SC QUERY %serviceName% | FIND "FAILED" >nul
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: GOTO Error%errorlevel%
:Error0
SC CREATE %serviceName% binPath= %servicePath% type= own start= auto
GOTO Restart
:Error1
@ECHO %serviceName% has been installed.
GOTO Restart
:Restart
NET START %serviceName% ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
PAUSE
|