启动脚本:
@echo off mode con cols=90 lines=20 title Windows 服务管理工具 -- Version 2016-09-01 09:00:00 ::------------------------------ 自动提升运行权限 ------------------------------:: :BatchGetAdmin >nul 2>&1 "%Windir%\System32\cacls.exe" "%Windir%\System32\config\system" if '%ERRORLEVEL%' NEQ '0' ( echo 正在获取管理员权限... 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 :gotAdmin if exist "%TEMP%\getadmin.vbs" ( del "%TEMP%\getadmin.vbs" ) pushd "%cd%" cd /d "%~dp0" ::------------------------------------------------------------------------------:: ::------------------------------ 启动 VMware 服务 ------------------------------:: :Start cls & echo. net start "VMAuthdService" net start "VMUSBArbService" net start "VMwareHostd" "C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" start "C:\Users\user\Documents\Virtual Machines\CentOS\CentOS.vmx" nogui ::------------------------------------------------------------------------------:: set "tip= VMware 服务启动完成" ::------------------------------------------------------------------------------:: ::--------------------------------- 倒计时退出 ---------------------------------:: :End for /l %%t in (0,-1,0) do ( cls & echo. && echo %tip% echo. & echo %%t 秒后退出... choice.exe /t 1 /d y /n >nul ) Exit
停止:
@echo off >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" if '%errorlevel%' NEQ '0' (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 if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) pushd "%CD%" CD /D "%~dp0" ::------------------------------ 启动 VMware 服务 ------------------------------:: :Start cls & echo. net stop "VMwareHostd" net stop "VMAuthdService" net stop "VMUSBArbService" ::------------------------------------------------------------------------------:: set "tip= VMware 服务已停止" ::------------------------------------------------------------------------------:: ::--------------------------------- 倒计时退出 ---------------------------------:: :End for /l %%t in (0,-1,0) do ( cls & echo. && echo %tip% echo. & echo %%t 秒后退出... choice.exe /t 1 /d y /n >nul ) Exit