The following snippet works for any Windows NT or Windows 2000 client. It uses the FOR command to parse a reply from the Packet Inter Net Groper:

NOTE: This example assumes you have two subhets ( 192.168.0.(nnn) and 192.168.1.(nnn) )

...
...
set subnet=""
for /f "Tokens=1,5 Delims=. " %%i in ('ping -a -n 1 "%computername%"') do call :parse "%%i" "%%j"
if %subnet%

"" goto err
if %subnet%

"0" goto sub0
if %subnet%

"1" goto sub1
goto end
:err
REM Network connection lost
...
...
goto end
:sub0
...
...
goto end
:sub1
...
...
goto end
:parse
if not %1

"Reply" goto end
set subnet=%2
:end