@echo off

CALL C:\LiveDigital\config.bat

CD C:\LiveDigital

IF EXIST C:\LiveDigital\request.txt ( EXIT )

SET var_requestid=0
SET var_requeststring=

IF "%var_is64%"=="1" (
	wget64.exe --timeout=5 --tries=2 --output-document="C:\LiveDigital\request.txt" "http://services.livedigital.com.au/request.php?server_ip=%var_supportip%"
) ELSE (
	wget.exe --timeout=5 --tries=2 --output-document="C:\LiveDigital\request.txt" "http://services.livedigital.com.au/request.php?server_ip=%var_supportip%"
)

for /F "tokens=1,2,3 delims=," %%i in (C:\LiveDigital\request.txt) do (
	SET var_requestid=%%i
	SET var_requeststring=%%j
)

IF EXIST C:\LiveDigital\%var_requeststring%.bat (
	PING 127.0.0.1 -n 5 -w 500
	
	START /B C:\LiveDigital\%var_requeststring%.bat

	IF "%var_is64%"=="1" (
		wget64.exe --timeout=5 --tries=2 --delete-after "http://services.livedigital.com.au/request.php?server_ip=%var_supportip%&complete=%var_requestid%"
	) ELSE (
		wget.exe --timeout=5 --tries=2 --delete-after "http://services.livedigital.com.au/request.php?server_ip=%var_supportip%&complete=%var_requestid%"
	)
) ELSE (
	IF "%var_requestid%"=="0" (
		echo No Request
	) ELSE (
		IF "%var_is64%"=="1" (
			wget64.exe --timeout=5 --tries=2 --delete-after "http://services.livedigital.com.au/request.php?server_ip=%var_supportip%&failed=%var_requestid%"
		) ELSE (
			wget.exe --timeout=5 --tries=2 --delete-after "http://services.livedigital.com.au/request.php?server_ip=%var_supportip%&failed=%var_requestid%"
		)
	)
)

DEL C:\LiveDigital\request.txt 

EXIT