It was a cleaner check. He deployed the script across all 200 servers via Group Policy.
When you use the self-elevating script method above, Windows will still show the UAC prompt (the screen dims and asks, "Do you want to allow this app to make changes to your device?"). force batch file to run as admin
@echo off :: Check for permissions IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" ( >nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" ) ELSE ( >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" ) :: If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" set params= %* echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" exit /B :gotAdmin pushd "%cd%" CD /D "%~dp0" :: --- YOUR ACTUAL SCRIPT STARTS BELOW THIS LINE --- echo Success! Running as Admin. pause Use code with caution. It was a cleaner check
: This closes the original, non-privileged window so you don't have two versions running at once. Important Tips Running as Admin
:: ========================================== :: YOUR ACTUAL SCRIPT GOES BELOW HERE :: ==========================================