@echo off setlocal set "SCRIPT_DIR=%~dp0" set "PS1=%SCRIPT_DIR%Enable-RemoteDesktopAccess.ps1" if not exist "%PS1%" ( echo [ERROR] PowerShell script not found: "%PS1%" exit /b 1 ) net session >nul 2>&1 if not "%ERRORLEVEL%"=="0" ( echo Requesting administrator permission... powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs -ArgumentList '%*'" exit /b ) echo Running as administrator: "%PS1%" 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] Remote Desktop settings finished successfully. exit /b 0