[Batch batch] A simple batch script to start VMware services

A simple batch script I wrote earlier to start a VMware service.
The main thing is to record the command to automatically elevate the running authority, no need to right-click and "run as administrator".
@echo off
mode with cols=90 lines=20
title Windows Service Management Tool -- Version 2016-09-01 09:00:00

::------------------------------- Auto-elevate running privileges------------- ----------------::
:BatchGetAdmin
>nul 2>&1 "%Windir%\System32\cacls.exe" "%Windir%\System32\config\system"

if '%ERRORLEVEL%' NEQ '0' (
echo getting admin rights...
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"
::------------------------------------------------------------------------------::

::------------------------------- Start VMware service--------------- ---------------::
:Start
cls & echo.
net start "VMAuthdService"
net start "VMUSBArbService"
net start "VMwareHostd"
net start "VMnetDHCP"
net start "VMware NAT Service"
::------------------------------------------------------------------------------::

set "tip= VMware service startup completed"
::------------------------------------------------------------------------------::

::-------------------------------- Countdown to exit------------- --------------------::
:End
for /l %%t in (3,-1,0) do (
cls & echo. && echo %tip%
echo. & echo %%t seconds to exit...
choice.exe /t 1 /d y /n >nul
)

Exit
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326515238&siteId=291194637