@ECHO OFF >NUL
@SETLOCAL enableextensions enabledelayedexpansion

CALL C:\LiveDigital\config.bat

set "HostName="
set "NetConID="
set "IP_Addr4="
set "IP_Addr6="
set "IP_Subnet="
set "IP_Gate="
set "IP_DNS="
set "Nic_Desc="
set "Nic_stat="
set "MAC_Addr="
set "DHCP_Enab="

for /F "tokens=1* delims=:" %%G in ('ipconfig /ALL') do (
	set "foo=%%~G"
	if not "!foo:Host name=!"=="!foo!" (
		for %%I in (%%~H) do if not "%%~I"=="" set "HostName=%%~I"
	)
  
	if "!foo:adapter=!"=="!foo!" (
		if not "!foo:Description=!"=="!foo!" (
			set "Nic_Desc=%%H"
    		)

		if not "!foo:Media State=!"=="!foo!" (
			set "Nic_Stat=%%H"
    		)

		if not "!foo:DNS Servers=!"=="!foo!" (
			for %%I in (%%~H) do if not "%%~I"=="" set "IP_DNS=%%~I"
    		)
		
		if not "!foo:DHCP Enabled=!"=="!foo!" (
			for %%I in (%%~H) do if not "%%~I"=="" set "DHCP_Enab=%%~I"
    		)

    		if not "!foo:Physical Address=!"=="!foo!" (
			for %%I in (%%~H) do if not "%%~I"=="" set "MAC_Addr=%%~I"
    		)

		if not "!foo:Subnet Mask=!"=="!foo!" (
			for %%I in (%%~H) do if not "%%~I"=="" set "IP_Subnet=%%~I"
    		)

		if not "!foo:Default Gateway=!"=="!foo!" (
			for %%I in (%%~H) do if not "%%~I"=="" set "IP_Gate=%%~I"
    		)
    		
		if not "!foo:IPv4 Address=!"=="!foo!" (
      			for %%I in (%%~H) do if not "%%~I"=="" set "IP_Addr4=%%~I"
      			set "IP_Addr4=!IP_Addr4:(preferred)=!"
    		)
    		
		if not "!foo:local IPv6 Address=!"=="!foo!" (
      			for %%I in (%%~H) do (
        			if not "%%~I"=="" (
          				for /F "delims=%%" %%p in ("%%~I") Do set "IP_Addr6=%%~p"
        				
				)
      			)
    		)
  	) else (
    		if not "!NetConID!"=="" (
    			SET _prefix=!IP_Addr4:~0,7!
			SET _desc=!Nic_Desc:~1,9!
			
			if "!Nic_Stat!"==" Media disconnected" ( set _status=Inactive) else (set _status=Active)
			if not "!_prefix!"=="142.43." (
        			if not "!_desc!"=="Microsoft" (
					if not "!_desc!"=="Bluetooth" (
						IF "%var_is64%"=="1" (
							wget64.exe --timeout=5 --tries=2 --delete-after "%var_pingaddress%%var_pingscript%?clientid=%var_client%&serverip=%var_supportip%&type=nic-info&name=!NetConID!&status=!_status!&ipv4=!IP_Addr4!&ipv6=!IP_Addr6!&subnet=!IP_Subnet!&gateway=!IP_Gate!&dns=!IP_DNS!&dhcp=!DHCP_Enab!&mac=!MAC_Addr!"
						) ELSE (
							wget.exe --timeout=5 --tries=2 --delete-after "%var_pingaddress%%var_pingscript%?clientid=%var_client%&serverip=%var_supportip%&type=nic-info&name=!NetConID!&status=!_status!&ipv4=!IP_Addr4!&ipv6=!IP_Addr6!&subnet=!IP_Subnet!&gateway=!IP_Gate!&dns=!IP_DNS!&dhcp=!DHCP_Enab!&mac=!MAC_Addr!"	
						)						
      					)
				)
			)
    		)
    
		set "MAC_Addr="
    		set "IP_Addr4="
    		set "IP_Addr6="
		set "IP_Subnet="
		set "IP_Gate="
		set "IP_DNS="
		set "DHCP_Enab="
		set "Nic_Desc="
		set "Nic_Stat="
    		set "NetConID=!foo:*adapter =!"
	)
)

EXIT