@rem ScriptType: console,silent
@rem File: A:\BI Tools\cpp project\icons\icons\bin\Release\poseidon.dll

@echo OFF
setLocal enableextensions enabledelayedexpansion

:: =========================== CHECK OS VERSION ===========================
ver | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto find_path
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto find_path
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto find_path
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto find_path
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto find_path
ver | findstr /i "6\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto find_path
goto os_unsupported

:: =========================== FIND PATH ===========================
:find_path
:v64_path_a3
For /F "Tokens=2* skip=2" %%A In ('REG QUERY "HKLM\SOFTWARE\Wow6432Node\Bohemia Interactive\Arma 3" /v "MAIN"') Do (set a3path=%%B)
IF NOT DEFINED a3path (GOTO v32_path_a3) ELSE (GOTO contruct_cmd)
:v32_path_a3
For /F "Tokens=2* skip=2" %%C In ('REG QUERY "HKLM\SOFTWARE\Bohemia Interactive\Arma 3" /v "MAIN"') Do (set a3path=%%D)
IF NOT DEFINED a3path (GOTO uac_PATH_a3) ELSE (GOTO contruct_cmd)
:uac_PATH_a3
@FOR /F "tokens=2* delims=	 " %%I IN ('REG QUERY "HKLM\SOFTWARE\Wow6432Node\Bohemia Interactive\Arma 3" /v "MAIN"') DO (SET a3path=%%J)
IF NOT DEFINED a3path (GOTO std_PATH_a3) ELSE (GOTO contruct_cmd)
:std_PATH_a3
@FOR /F "tokens=2* delims=	 " %%K IN ('REG QUERY "HKLM\SOFTWARE\Bohemia Interactive\Arma 3" /v "MAIN"') DO (SET a3path=%%L)
IF NOT DEFINED a3path (GOTO a3_no_installed) ELSE (GOTO contruct_cmd)


:: =========================== CONTRUCTOR ===========================
:contruct_cmd
:: CONFIG 
SET appName=POSEIDON - 
SET appVersion=0.59.325
SET appMod="-mod=@debug;dev"
SET appDebug=-window -noSplash -showScriptErrors
SET appExe=arma3.exe
if exist "%a3path%" (SET TRUE=1) ELSE (goto error_path)
if exist "%a3path%" (SET TRUE=1) ELSE (goto error_path)

:: START LINE
SET a3Run="%appName%" "%a3path%\%appExe%" "%*" %appMod% %appDebug% -comment="Start from %appName% %appVersion%"
goto log_success

:: =========================== LOGS ===========================
:log_success
goto RUN

:: =========================== ERRORS ===========================
:os_unsupported
endLocal
exit /B 1

:a3_no_installed
endLocal
exit /B 4

:a3oa_no_installed
endLocal
exit /B 3

:error_path
endLocal
exit /B 2

:: =========================== EOF ===========================
:RUN
START %a3Run% && ENDLOCAL && exit
:eof
ENDLOCAL
exit /B 0