cmd 提高權限 script
最近Client端電腦Windows 10 版號1909 更新到2004後,發現到原本用戶端的Windows Firewall有設定Enable ICMP,但是作業系統更新到2004後,竟然被Disable了,因為Client端並未Join AD Domain,所以只好透過第三方軟體來派送Script,並且撰寫腳本來提升權限,方法如下: 建立腳本檔案(編碼:ANSI),名稱:RunCmdElevated.bat,內容如下: :: BatchGotAdmin (Run as Admin code starts) REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> 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" 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"