View Single Post
Old 02-20-2012, 05:24 AM
aladdin aladdin is offline
Senior Member
Join Date: Sep 2008
Posts: 66

[Please DO NOT reply to yourself, use the Edit button to edit your post]

I'm really sorry for that zementmischer.

Yeah I was asking for a batch file which should ask in that particular order but when I googled it then I found my mentioned codes that 100% work.

Technically I was asking for an automatic IP changer in batch form which can either ask IPs/Gateway or these can be defined in a batch file at a particular place. Therefore, I got the latter.


Please consider the following codes:

set varip=
set varsm=
set vargw=
set vardns1=
set vardns2=
REM ***** You donít need to change anything below this line! ******
ECHO This fanciness is brought to you by Saman Sadeghi!

ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm%
ECHO Setting Gateway
netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 

ECHO Setting Primary DNS
netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%
ECHO Setting Secondary DNS
netsh int ip add dns name = "Local Area Connection" addr = %vardns2%
ECHO Here are the new settings for %computername%:
netsh int ip show config
Now I want to ask one more thing after running the above codes in batch file.

I go to TCP/IP Properties > Advanced and I found already entered in Default Gateway field.

Now the problem is: I want to add one more gateway in Default Gateway field which is with Metric 50

What additional lines should I add in my batch file in order to do that?


Thanks in advance.

Last edited by Git : 02-20-2012 at 07:56 AM.
Reply With Quote