获取管理员权限
@echo off >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" if '%errorlevel%' NEQ '0' ( echo run as administrator... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" exit /B :gotAdmin
停止、启动服务
@title 重启服务 net stop 服务名 net start 服务名 exit
标签:bat,服务,temp%,windows,getadmin,cmd,echo,vbs,管理员 From: https://www.cnblogs.com/SherryIce/p/16711187.html