Script for Fast IP address switching in Windows 7

Source: Internet
Author: User
Tags dns2

I use a dynamic IP Address at home and a fixed IP address in my 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!

 @ echo offrem // set the variable set name = "Local Connection" REM // The following attribute values can be changed as needed: Set ADDR = 172.16.18.184set mask = 255.255.255.0set gateway = 172.16.18.254set dns1 = 172.16.17.1set dns2 = 8.8.8.8rem/the above attributes are IP addresses, subnet masks, gateways, preferred DNS, and alternate dnsecho currently available operations: echo 1 is set to static ipecho 2 is set to dynamic ipecho 3 Exit echo select and press Enter: set/P operate = If % operate % = 1 goto 1if % operate % = 2 goto 2if % operate % = 3 goto 3: 1 ECHO is setting static IP, please wait... rem // Root Modify the echo IP address as needed = % 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 already set! Pausegoto 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" dhcpecho is automatically obtaining the DNS address from DHCP... netsh interface IP Set DNS "Local Connection" DHCP Echo Dynamic IP address set! Pausegoto 3: 3 Exit 

Min bin(Write to meOriginal blog (http://blog.csdn.net/binbinxyz), reprinted please noteSource!

 

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.