- powershell -Command "if((New-Object System.Security.Principal.WindowsPrincipal -ArgumentList @([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)){exit 0}else{exit 1}"
- if %errorlevel% equ 0 (
- echo 管理员.
- ) else (
- echo 不是管理员.
- )
复制代码
|