@echo off
setlocal EnableExtensions
title LunaSupport - Temporary Remote UAC Prompt Disable

net session >nul 2>&1
if not "%errorlevel%"=="0" (
  echo Administrator privileges are required.
  echo Right-click this file and choose "Run as administrator".
  pause
  exit /b 1
)

set "LS_DIR=%ProgramData%\LunaSupport"
if not exist "%LS_DIR%" mkdir "%LS_DIR%" >nul 2>&1
set "BACKUP=%LS_DIR%\UAC_Prompt_Backup.reg"

echo LunaSupport Remote Support
echo ==========================
echo This temporarily removes UAC consent prompts for administrator accounts.
echo UAC remains enabled. Restore the prior settings immediately after support.
echo.

if not exist "%BACKUP%" (
  reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "%BACKUP%" /y >nul
  if errorlevel 1 (
    echo ERROR: Unable to back up current UAC settings.
    pause
    exit /b 1
  )
)

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 1 /f >nul
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f >nul
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v PromptOnSecureDesktop /t REG_DWORD /d 0 /f >nul

echo DONE.
echo Run LunaSupport_Remote_UAC_Prompt_Restore.cmd when support is finished.
pause
endlocal
