|
| |||||||||
| Tags: batch coding, batch file, ip tool |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Create a simple IP Tool Batch File.
Hey guys! I'm new to batch programming. According to my understanding, batch file is logical collection of commands recognised by dos. I am familiar with most of the commands. I want to create a tool which can do three things as follows : 1 - show ip configurations 2 - add ip address 3 - exit any idea? i don't know how to use loops and jumps. can any one guide me?? |
|
#2
| ||||
| ||||
| Re: Create a simple IP Tool Batch File. Code: @echo OFF :Start echo Enter 1 to show TCP/IP Configuration echo Enter 2 to add IP ADDRESS echo Enter 3 to Exit ECHO Enter Choice. SET /P variable= IF %variable%==3 exit IF %variable%==2 GOTO IPAD IF %variable%==1 GOTO IPSH :IPSH ipconfig /all GOTO Start :IPAD echo Enter IP address in dotted format [ex: 192.168.10.100] : Set /P variable1= echo Enter subnet mask in dotted format [ex: 255.255.25.0] : Set /P variable2= echo Enter the name of you network connection [ex: Local Area Connection, Lan] : Set /P variable3= netsh interface ip add address %variable3% %variable1% %variable2% GOTO Start Have Fun...! |
|
#3
| |||
| |||
| Re: Create a simple IP Tool Batch File.
Hey Man! Thanks a lot i've copied the code in notepad and saved it as ".bat" for batch file... I ran it by double clicking on it..! It runs great! Thanks man!! I owe this to you...! |
|
#4
| ||||
| ||||
| Re: Create a simple IP Tool Batch File.
Don't Mention it! There's something more for you... I just did some research and added two more features :
Heres the complete code : Code: @echo OFF :Start echo Enter 1 to show TCP/IP Configuration echo Enter 2 to add IP ADDRESS echo Enter 3 to add gateway echo Enter 4 to add dns echo Enter 5 to Exit ECHO Enter Choice. SET /P variable= IF %variable%==5 exit IF %variable%==4 GOTO DNSAD IF %variable%==3 GOTO GWAD IF %variable%==2 GOTO IPAD IF %variable%==1 GOTO IPSH :IPSH ipconfig /all GOTO Start :IPAD echo Enter IP address in dotted format [ex: 192.168.10.100] : Set /P variable1= echo Enter subnet mask in dotted format [ex: 255.255.25.0] : Set /P variable2= echo Enter the name of you network connection [ex: Local Area Connection, Lan] : Set /P variable3= netsh interface ip add address %variable3% %variable1% %variable2% GOTO Start :GWAD echo Enter the name of you network connection [ex: Local Area Connection, Lan] : Set /P variable3= echo Enter gateway in dotted format [ex: 192.168.10.100] : Set /P variable4= netsh interface ip add address "%variable3%" gateway=%variable4% gwmetric=2 GOTO Start :DNSAD echo Enter the name of you network connection [ex: Local Area Connection, Lan] : Set /P variable3= echo Enter primary adns ddress in dotted format [ex: 10.168.115.105] : Set /P variable5= echo Enter secondary dns address in dotted format [ex: 10.168.115.105] : Set /P variable6= netsh interface ip add dns %varialbe3% %variable5% netsh interface ip add dns %varialbe3% %variable6% index=2 GOTO Start |
|
#5
| |||
| |||
| Re: Create a simple IP Tool Batch File.
MSpace... Your a genius... Was just tryin to figure it out the same... Thanks again...! So anymore problem i'll PM you instead posting here...! |
|
#6
| ||||
| ||||
| Re: Create a simple IP Tool Batch File. I suggest whatever problem you have, post it here. Not only you but if someone else has the same problem will be helped...!All the best! Try it out... if you discover something... do post...! |
|
#7
| |||
| |||
Re: Create a simple IP Tool Batch File.
hi Mspace, new out here.. saw your replies, seems your are good with batch files , so thought you could help me with this : I got two routers and single LAN card. that means 2 gateways and 2 sets of dns. I am trying to write a batch file, which on double clicking it, will alternate within the given gateways and dns's. Currently i've 2 .bat files - 1.bat and 2.bat. If i want to switch to router 1, i click 1.bat, and if the 2nd router, i double click 2.bat. I want to write a batch file which checks what gateway it is in, and switches to other. thank you ![]() |
|
#8
| ||||
| ||||
| Re: Create a simple IP Tool Batch File.
Hey! Try this : Code: @echo OFF :Start echo Enter 1 to Switch to 1st DNS and Gateway echo Enter 2 to Switch to 2nd DNS and Gateway echo Enter 3 to Exit ECHO Enter Choice. SET /P variable= IF %variable%==3 exit IF %variable%==2 GOTO one IF %variable%==1 GOTO two :one [here enter path of the 1.bat file without these box bracket] :two [here enter path of the 2.bat file without these box bracket] :exit exit |
|
#9
| |||
| |||
Re: Create a simple IP Tool Batch File.
@myspace: no no.. dude, thats not what i meant.. my requirement is : 1. I want a single bat file. 2. when i double click that file, it should switch to other gateway. in case you didn't clearly understand, here is the real situation in detail: there are 2 routers, r1 and r2. so there are 2 gateways , 192.168.1.1 and 192.168.1.2 when I double click the batch file, it should check which gateway I am currently using, and it should shift to other gateway. Like if the current default gateway is 192.168.1.1, if i double click the .bat file, it should set current gateway as 192.168.1.2. I actually created what you suggested by looking at the microsoft kb articles on netsh long ago, but the problem i am facing now is that i dont know how to extract only the gateway from netsh command so that i can use in "if else" check statement in dos commands. FYI, netsh int ip show address "local area connection" this statement gets the ip address, subnet mask, gateway, etc from the local area connection adapter. if there is a way to extract the gateway or something like that, we could use the if else construct and do the batch file. thank you for your co operation ![]() |
|
#10
| |||
| |||
| Re: Create a simple IP Tool Batch File.
shrinath_m2, i had the same problem and used this... batch file # 1 netsh interface ip set address name="Local Area Connection" static 192.168.1.3 255.255.255.0 192.168.1.1 1 batch file # 2 netsh interface ip set address name="Local Area Connection" static 192.168.1.3 255.255.255.0 192.168.1.2 1 batch file # 3 ipconfig | find "192.168.1.1" if not errorlevel 1 goto set2 call 192.168.1.1.bat goto :end :set2 call 192.168.1.2.bat :end exit run batch file #3 and no mather what gateway you're on it will switch to the other one. hope it helps |
|
#11
| |||
| |||
| Re: Create a simple IP Tool Batch File.
I need to create a batch file that whenever a connection is not present on my PC,it will release and renew IP automatic. Can anyone help please ? |
|
#12
| |||
| |||
| Help Require !! Quote:
Dear One, I want to do two things :- 1. change only Gateway while using batch file through @echo off 2. want to add multi IP using batch file can you please help me in this regard. Shahid Akhtar |
|
#13
| |||
| |||
| Re: Create a simple IP Tool Batch File.
Dear Mind Space i think you are genius , i am facing a problem, and i want please help me as soon as you can when i want to access some web sites that local ip filter blocks those sites . internet provider proxy has blocked those sites, so i want create a bat file that should bypass the local ip filter and hide my ip address and local internet proxy should not filter my browsing, i mean when connect to the internet my ip address should be from united states of ammerica in spite of united arab emirates Asif Raza From united arab emirates |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Create a simple IP Tool Batch File." | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to make a simple Sorting batch file? | nadeth | Software Development | 3 | 3 Weeks Ago 06:13 AM |
| How to create a simple logo in Illustrator Tool | L 4 Life | Windows Software | 4 | 17-01-2011 08:01 AM |
| Create All in one system utility Software with simple batch programming | MindSpace | Software Development | 0 | 07-03-2009 01:39 PM |
| A Simple File and Folder renaming batch code : RenameR | Rudra.J | Tips & Tweaks | 2 | 05-03-2009 02:59 PM |
| How to create a Batch file | Katty | Software Development | 1 | 10-01-2009 01:26 PM |