Use batch processing to set IP addresses in Windows

Source: Internet
Author: User
Tags get ip

Sometimes, when changing the network environment of a computer, you may need to set the IP address of the computer. If you click Network Connection> Properties> ip address every time, it is not too cumbersome. Next I will introduce how to use batch processing to set the IP address of a computer.


Sometimes, when changing the network environment of a computer, you may need to set the IP address of the computer. If you click Network Connection> Properties> ip address every time, it is not too cumbersome. Next I will introduce how to use batch processing to set the IP address of a computer.

Script usage: first create a text file, change the suffix to ". cmd" or ". Bat", and thenCodePartially paste it in, save, and close the file. Right-click the file and select "open" (you need to select "Run as administrator" for Windows 7 ).ArticleAt last, I will list all four batch files.

I. settings in Windows 7

1. automatically obtain the IP Address:

@ Echo offecho ---- From garfieldjiang column automatically obtain the IP address batch processing file --- echo ----- http://hi.csdn.net/jiangzhanchang------------------echo -------------------------------------------------------- ECHO is setting to automatically obtain the IP address, please wait ...... netsh interface IPv4 set address name = "Local Connection" Source = DHCP: the above Code sets the IP address to automatically obtain the netsh interface IPv4 set DNS name = "Local Connection" Source = DHCP: the above code sets automatic DNS retrieval: the "local connection" in the above Code can be changed to another one as needed, such as "wireless network connection" If % errorlevel % = 0 (netsh Interface IPv4 show IP) else (echo --------------------- error! ----------------- & Echo error code: % errorlevel % & Echo right-click and choose "Run as administrator" & Echo -------------------------------------------------) pause

2. manually set the IP Address:

@ Echo offecho ---- From garfieldjiang column automatically get IP address batch processing file --- echo ----- http://hi.csdn.net/jiangzhanchang------------------echo -------------------------------------------------------- ECHO is manually set IP address, please wait ...... netsh interface IPv4 set address "Local Connection" static 192.168.0.100 255.255.255.255.0 192.168.0.1: The above line of address is: IP address, subnet mask, default gateway netsh interface IPv4 set dnsservers "Local Connection" static 192.168.0.1 primary: set the primary DNS server address net in the previous line. Sh interface IPv4 set dnsservers "Local Connection" static 192.168.0.1: Set the secondary DNS server address in the previous line: the "local connection" in the above Code can be changed to another one as needed, for example, "wireless network connection" If % errorlevel % = 0 (netsh interface IPv4 show IP) else (echo ------------------- error! ----------------- & Echo error code: % errorlevel % & Echo right-click and choose "Run as administrator" & Echo -------------------------------------------------) pause

Ii. settings in Windows XP

1. automatically obtain the IP Address:

 
@ Echo offecho ---- From garfieldjiang column automatically obtain the IP address batch processing file --- echo ----- http://hi.csdn.net/jiangzhanchang------------------echo -------------------------------------------------------- ECHO is setting to automatically obtain the IP address, please wait ...... netsh interface IP Set address name = "Local Connection" Source = DHCP: the above Code sets the IP address to automatically obtain the netsh interface IP Set DNS name = "Local Connection" Source = DHCP: the above code sets automatic DNS retrieval: the "local connection" in the above Code can be changed to another one as needed, such as "wireless network connection" If % errorlevel % = 0 (netsh int Erface IP show IP) else (echo --------------------- error! ----------------- & Echo error code: % errorlevel % & Echo right-click and choose "Run as administrator" & Echo -------------------------------------------------) pause

2. manually set the IP Address:

 
@ Echo offecho ---- From garfieldjiang column automatically get IP address batch processing file --- echo ----- http://hi.csdn.net/jiangzhanchang------------------echo -------------------------------------------------------- ECHO is manually set IP address, please wait ...... netsh interface IP Set address "Local Connection" static 192.168.0.100 255.255.255.0 192.168.0.1: The above line of addresses are: IP address, subnet mask, default gateway netsh interface IP Set dnsservers "Local Connection" static 192.168.0.1 primary: set the primary DNS server address netsh I in the previous line. Nterface IP Set dnsservers "Local Connection" static 192.168.0.1: Set secondary DNS server address in the previous line: the "local connection" in the above lines of code can be changed to another one as needed, for example, "wireless network connection" If % errorlevel % = 0 (netsh interface IP show IP) else (echo ------------------- error! ----------------- & Echo error code: % errorlevel % & Echo right-click and choose "Run as administrator" & Echo -------------------------------------------------) pause

Batch files: http://download.csdn.net/detail/jiangzhanchang/3910319

If you need to reprint, please note: Reprinted from "garfieldjiang's column"Http://hi.csdn.net/jiangzhanchang

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.