Windows批处理开启/停止服务及隐藏批处理窗口

1、bat编写你要开启的服务

@echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
net start Acunetix
net start "Acunetix Database"
pause



2、bat编写你要停止的服务

@echo off
@sc stop Acunetix
@sc stop "Acunetix Database"

3、Windows下隐藏批处理窗口

@echo off
if "%1"=="h" goto begin
start mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin

::以下为正常批处理命令,不可含有pause set/p等交互命令

pause

注意:服务名称如果是多个字符中间有空格的话,需要给服务名加上双引号 ""

echo on的意思是显示命令回显
echo off的意思就是关闭回显
在指令前加上“@”来无视当前回显状态,让某些指令关闭回显
@echo off  不显示后续命令行及当前命令行
pause 运行此句会暂停批处理的执行并在屏幕上显示Press any key to continue...的提示,等待用户按任意键后继续

调用管理员权限:
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit

原文地址:https://www.cnblogs.com/qtzd/p/15569966.html