Script for Fast IP address switching in Windows 7

Source: Internet
Author: User
Tags dns2

In Windows 7, I use a dynamic IP Address at home and a fixed IP address at the company, so I often need to switch back and forth ipsettings, which is very troublesome! Today, I can't bear it. I have compiled a script to ease the trouble of switching back and forth IP addresses! For fear of forgetting, please keep a record! [Plain] @ echo off rem // set the variable set NAME = "Local Connection" rem // The following attribute values can be changed as needed: set ADDR = 172.16.18.184 set MASK = 255.255.255.0 set GATEWAY = 172.16.18.254 set DNS1 = 172.16.17.1 set DNS2 = 8.8.8.8 rem // The above attributes are IP address, subnet mask, gateway, preferred DNS, and backup DNS echo. Currently available operations include: echo 1 is set to static IP echo 2 is set to dynamic IP echo 3 Exit echo select and press Enter: set/p operate = if % operate % = 1 goto 1 if % operate % = 2 goto 2 if % operate % = 3 goto 3: 1 echo is setting static IP, please wait... rem // you can To change the echo IP address = % ADDR % echo MASK = % mask % echo GATEWAY = % GATEWAY % netsh interface ipv4 set address name = % NAME % source = static addr = % ADDR % MASK = % MASK % gateway = % GATEWAY % gwmetric = 0> nul echo preferred DNS = % DNS1 % netsh interface ipv4 set dns name = % NAME % source = static addr = % DNS1 % register = PRIMARY> nul echo backup DNS = % DNS2 % netsh interface ipv4 add dns name = % NAME % addr = % DNS2 % index = 2> nul echo static IP address set! Pause goto 3: 2 echo is setting a dynamic IP address. Please wait... echo is automatically obtaining the IP address from DHCP... netsh interface ip set address "Local Connection" dhcp echo is automatically obtaining the DNS address from DHCP... netsh interface ip set dns "Local Connection" dhcp echo Dynamic ip address set! Pause goto 3: 3 exit Source http://blog.csdn.net/binbinxyz/article/details/8876855

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.