JSI Tip 2150. How do I alter my logon script logic based upon a clients subnet?

Jerold Schulman

March 14, 2000

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like