@echo off
if not DEFINED IS_LOCK_MINIMIZED set IS_LOCK_MINIMIZED=1 && start "TAC: Prevent Screen Lock" /min "%~dpnx0" %* && exit
echo ========================================
echo ========================================
echo =====                              =====
echo ===== Please minimize this window. =====
echo =====                              =====
echo ========================================
echo ========================================
set AGENT_FOLDER=%~dp0
echo Agent is running at: %AGENT_FOLDER%
%~d0
cd "%AGENT_FOLDER%"
md logs\agent 2> nul

REM Check for local Java in AGENT_FOLDER
set JAVA_CMD=java
if exist "%AGENT_FOLDER%java\bin\java.exe" (
    set JAVA_CMD="%AGENT_FOLDER%java\bin\java.exe"
    echo Using local Java: %JAVA_CMD%
) else (
    echo Using system Java: %JAVA_CMD%
)

cd tools
set IS_LOCK_MINIMIZED=
%JAVA_CMD% -cp .;DataHandling.j4n.jar;jni4net.j-0.8.8.0.jar NoScreenLock >> ..\logs\agent\prevent-log.log
exit
