REM CMDOW @ /HID

CALL C:\LiveDigital\config.bat

CD C:\LiveDigital

@echo off

setlocal enabledelayedexpansion
IF "%var_is64%"=="1" (
	wget64.exe --output-document browse.txt --delete-after http://www.livedigital.com.au/scripts/access-list.php
	wget64.exe --user-agent="Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 (LiveBot 1.0 - ^%var_hostname%)" --save-cookies cookies.txt --keep-session-cookies --delete-after http://www.livedigital.com.au/

) ELSE (
	wget.exe --output-document browse.txt --delete-after http://www.livedigital.com.au/scripts/access-list.php
	wget.exe --user-agent="Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 (LiveBot 1.0 - ^%var_hostname%)" --save-cookies cookies.txt --keep-session-cookies --delete-after http://www.livedigital.com.au/
)

for /F "tokens=*" %%A in (browse.txt) do (
	set "addr="
	set "wait="
	set "agent=Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 (LiveBot 1.0 - ^%var_hostname%)"
	
	for /f "tokens=1,2 delims= " %%i in ("%%A") do (
		set addr=%%i
		set wait=%%j
	)
	echo addr: !addr!
	echo agent: !agent!
	echo wait: !wait!
	
	ping 192.0.0.0 -n 1 -w !wait! > nul
	IF "%var_is64%"=="1" (
		wget64.exe --user-agent="!agent!" --load-cookies cookies.txt --delete-after !addr!
	) ELSE (
		wget.exe --user-agent="!agent!" --load-cookies cookies.txt --delete-after !addr!
	)
)

del browse.txt
del cookies.txt

EXIT