There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware help please hijackthis hjt hjt log install internet internet explorer itunes javascript keyboard laptop log malware monitor network networking openoffice outlook outlook 2003 outlook express password popups problem router seo slow sound sp3 spyware startup trojan usb video virtumonde virus vista vundo windows windows xp winxp wireless youtube
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
.bat file to check ip range then do work


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
G-Stress's Avatar
Member with 96 posts.
 
Join Date: Feb 2008
24-Apr-2008, 01:03 AM #1
.bat file to check ip range then do work
Just had a good Idea and not sure where to get started. I want to create a .bat file that checks ip's and if an ip is = to say 192.168.1.101 or if the adapter falls in the say 192.168.1.? range then DO this...

just not sure how to tell it to check the ip or ip ranges.
TheOutcaste's Avatar
Computer Specs
Senior Member with 1,538 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
24-Apr-2008, 02:35 AM #2
Code:
:::::::::::::::::::::::::::::::::::::::::::::::::::
:Checks a range of IP addresses then performs
:an action based on whether the system responded
:to a ping command. Note that if the system has
:a firewall set to ignore pings, it will appear
:to be not present. Set _t4 to the first 3 numbers
:of the IP address. This example will check
:192.168.9.10 through 192.168.9.20
:::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal enabledelayedexpansion
:Timeout for ping command in milliseconds
Set _t0=500
:start IP (last number)
Set _t1=10
:ending IP (last number)
Set _t2=20
Set _t4=192.168.9.
for /L %%I in (%_t1%,1,%_t2%) do set _t3=%%I & (ping %_t4%%%I -n 1 -w %_t0% >nul
) & call:_e!errorlevel!
echo All IPs tested
:::::::::::::::::::::::::::::::::::::::::::::::::::
:clear the temp variables that were used
:::::::::::::::::::::::::::::::::::::::::::::::::::
for /L %%I in (0,1,4) do set _t%%I=
goto:eof
:::::::::::::::::::::::::::::
:End of main
:::::::::::::::::::::::::::::
:Subroutines Below here
:::::::::::::::::::::::::::::::::::::::::::::::::::
:Enter code to execute if the IP address is present in this section
:::::::::::::::::::::::::::::::::::::::::::::::::::
:_e0
echo %_t4%%_t3% exists
goto:eof
:::::::::::::::::::::::::::::::::::::::::::::::::::
:Enter code to execute if the IP address is not present in this section
:::::::::::::::::::::::::::::::::::::::::::::::::::
:_e1
Echo %_t4%%_t3% does not exist
goto:eof
This will do it, unless ping has been blocked. Ping followed by an arp command could work around that. Need some experimenting for that.

Jerry
G-Stress's Avatar
Member with 96 posts.
 
Join Date: Feb 2008
26-Apr-2008, 08:16 PM #3
Thanks Jerry,

I understand this for the most part I'm gonna play around with it and look online first to see what exactly does what toward the middle of the code to see if I can understand better and have some fun with this.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:45 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.