Jump to content
xisto Community
curare

Switch Network Settings With Batch Files A quick way to change IP, Gateway, DNS

Recommended Posts

Vista settings

Switch Network Settings With Batch Files

 

Emmy- that's because you need to type the following into a batch file:

 

@ECHO OFF

 

Set varip=192.168.0.99

Set varsm=255.255.255.0

Set vargw=192.168.0.100

Set vardns1=195.131.131.11

Set vardns2=195.131.131.12

 

ECHO Setting IP to static

Netsh int ipv4 set address name = "LAN-verbinding 4" source = static address = %varip% mask = %varsm%

 

ECHO Setting IP Address and Subnet Mask

Netsh int ipv4 set address name = "LAN-verbinding 4" address = %varip% mask = %varsm% gateway = %vargw% gwmetric = 1

 

ECHO Setting Primary DNS

Netsh int ip set dns name = "LAN-verbinding 4" source = static addr = %vardns1%

 

ECHO Setting Secondary DNS

Netsh int ip add dns name = "LAN-verbinding 4" addr = %vardns2%

 

ECHO Here are the new settings for %computername%:

Netsh int ip show config

 

Pause

 

-reply by Razzor

Share this post


Link to post
Share on other sites

Vista problems

Switch Network Settings With Batch Files

 

Hiya,

 

Have you tried running it by right clicking and using 'run as administrator' instead.

 

It worked for me as I was getting the:

 

This command needs to be elevated

 

HTH

 

-reply by Andy Holland

Share this post


Link to post
Share on other sites

Thanks

Switch Network Settings With Batch Files

 

I'm using vista but it didn't work as mentioned above

 

I tried

 

Set address name="Wireless Network Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1

 

And now it works perfectly!

 

-reply by Quang Tran

Share this post


Link to post
Share on other sites

how to add the one more ip address to a batch file

Switch Network Settings With Batch Files

 

Hi,

 

 

Iam Rajkumar working in crystal granite marble pvt ltd.

 

 

Here our lan ip is 192.168.0.1 subnetmask is 255.255.255.0

 

And internet ip is 10.7.192.81 subnetmask is 255.255.255.240

 

 

I want to add the one moreip address to the above mentioned batchfile

 

 

I can add the one more dns also but iam not able to add the ip address

 

 

Please help me in this scenario

 

 

 

Thnaks and Regards,

Rajkumar.S

 

-reply by RAJKUMAR

Share this post


Link to post
Share on other sites

Excellent post.

I'm a little lazy, and found some freeware - "NetSetMan". Works fine for me, and can hold up to 6 different network profiles.

Thanks to all.

- Andy

Share this post


Link to post
Share on other sites
Alternate ScriptSwitch Network Settings With Batch FilesI couldn't quite get these working, however I modded a couple of scripts together and the script below works for me on Vista.@ECHO OFFSet varNet="Wireless Network Connection"Set varip=192.168.0.1Set varsm=255.255.255.0Set vargw=192.168.0.2Set vardns1=192.168.0.3Set vardns2=192.168.0.4ECHO Setting IP Address, Subnet Mask and GatewayNetsh int ip set address name = %varNet% source = static addr = %varip% mask = %varsm% gateway = %vargw% gwmetric = 1ECHO Setting Primary DNSNetsh int ip set dns name = %varNet% source = static addr = %vardns1%ECHO Setting Secondary DNSNetsh int ip add dns name = %varNet% addr = %vardns2%-reply by Noot

 

Share this post


Link to post
Share on other sites
What settings?Switch Network Settings With Batch Files

I got the right command in the batch file but it doesn't change my IP. Do I have to have a static IP address to make this work? My friend said I won't have to change it. When I do ipconfig after the batch file launch EVERYTHING is still the same, how?

Share this post


Link to post
Share on other sites
Thanks a lotSwitch Network Settings With Batch Files

Thanks a lot curare..

But it was the solution of Quang that saved me. I guess they changed the parameters on Vista.

 So thanks to you both,

 Cheers

Keywords: save ip address different network

Share this post


Link to post
Share on other sites

simply amazing man...U solved my problem,was struggling to do this for long...Thanx...Take care,keep up the good work

-reply by Faisal

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.