goto based on IP Address

Posted on 2008-02-11
Medium Priority
Last Modified: 2010-04-21
Hi all,

I'm trying to create a batch file command that runs from the login script.

We have numerous sites and numerous subnets to go with it. What I want to do is use a goto based on the second segment of the IP, for example:

If the IP address =, I need to identify the 150 segment of the address and use that to head to a goto instruction, else end.

It's a command that I only want to run if a user is on a specific site, hence the reason for the split.
Question by:WRumbled
  • 2
LVL 26

Accepted Solution

Farhan Kazi earned 1000 total points
ID: 20867335
Try following batch code if this works for you!

FOR /F "tokens=2 delims=:" %%i IN ('IPConfig ^|FIND /I "IP Address"') DO SET IP=%%i
FOR /F "tokens=2 delims=. " %%i IN ('ECHO %IP%') DO SET Octet=%%i
IF NOT %Octet% EQU 150 GOTO :ENDScript
ECHO To do...

Open in new window


Author Closing Comment

ID: 31429805
Perfect, thank you very much.

Author Comment

ID: 20867552
That worked perfectly. Thanks.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question