Skip navigation

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

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

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish