@echo off setlocal set "SCRIPT_DIR=%~dp0" set "PS1=%SCRIPT_DIR%%~n0.ps1" rem Check administrator privileges net session >nul 2>&1 if not "%ERRORLEVEL%"=="0" ( echo Requesting administrator privileges... powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -ArgumentList '%*' -Verb RunAs" if not "%ERRORLEVEL%"=="0" ( echo [ERROR] Failed to request administrator privileges. exit /b 1 ) exit /b ) if not exist "%PS1%" ( echo [ERROR] PowerShell script not found: "%PS1%" exit /b 1 ) echo Running "%PS1%" as administrator... powershell -NoProfile -ExecutionPolicy Bypass -File "%PS1%" %* set "RC=%ERRORLEVEL%" if not "%RC%"=="0" ( echo [ERROR] Script finished with exit code %RC% exit /b %RC% ) echo [OK] Script finished successfully. exit /b 0