@ECHO OFF

CALL C:\LiveDigital\config.bat

SETLOCAL EnableDelayedExpansion

IF EXIST C:\LiveDigital\tools\memory\memory-total.txt (
	REM Total Memory Files Already Exists
) ELSE (
	SET /A loopIndex=0
	FOR /f "skip=1" %%G IN ('wmic ComputerSystem get TotalPhysicalMemory') DO (
		
		SET /A loopIndex+=1
		IF !loopIndex!==1 (
			SET totalRAM=%%G
			@ECHO TotalRAM !totalRAM!
		)
	)
)

SET /A loopIndex=0
FOR /f "skip=1" %%G IN ('wmic os get FreePhysicalMemory') DO (
	SET /A loopIndex+=1
	IF !loopIndex!==1 (
		SET /A freeRAM=%%G*1024
		@ECHO FreeRAM !freeRAM!
	)
)

if !totalRAM! LSS 0 SET /a totalRAM=0-!totalRAM!
if !freeRAM! LSS 0 SET /a freeRAM=0-!freeRAM!

IF "%var_is64%"=="1" (
	wget64.exe --delete-after "%var_pingaddress%%var_pingscript%?clientid=%var_client%&serverip=%var_supportip%&type=system-ramusage&total=!totalRAM!&free=!freeRAM!"
) ELSE (
	wget.exe --delete-after "%var_pingaddress%%var_pingscript%?clientid=%var_client%&serverip=%var_supportip%&type=system-ramusage&total=!totalRAM!&free=!freeRAM!"
)

@ECHO Available RAM !freeRAM!B / !totalRAM!B
EXIT