Thursday, November 15, 2018

script - IP, Gateway and DNS changer [.bat Win7]

I have a batch file that I use on my WinXP SP3 (I found it on the net and it worked).


SWiTCH TO CONNECTION 1



@ECHO OFF set varip=192.168.0.118 set varsm=255.255.255.0 set
vargw=192.168.0.1 set vardns1=121.1.3.81 set vardns2=121.1.3.16


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 = 1


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%



SWITCH TO CONNECTION 2



@ECHO OFF set varip=192.168.0.118 set varsm=255.255.255.0 set
vargw=192.168.0.2 set vardns1=192.168.0.2 set vardns2=192.168.0.8


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 = 1


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%



Unfortunately this batch file does not work on my Win7 (ultimate) machine. I am wondering what to edit to make it work. I've searched some sites and tried a thing or two but I was not able to find a solution. Thank you very much in advance for the help.

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...