@echo off
title Siraya Printer Fix
color 0E

>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
    echo Click YES on admin prompt...
    goto UACPrompt
) else (
    goto gotAdmin
)

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\siraya_fixadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\siraya_fixadmin.vbs"
    "%temp%\siraya_fixadmin.vbs"
    exit /B

:gotAdmin
cd /d "%~dp0"
echo.
echo  Fixing Siraya printer agent (port 5000)...
echo.
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0fix-printer-agent.ps1"
pause
