Use netsh in Windows2000/XP to dynamically switch the IP address of the host

Source: Internet
Author: User
In Win2000/XP, you can use netsh provided by windows to create a script to dynamically switch IP addresses. if a machine needs to switch between different CIDR blocks, you do not need to change the IP address each time.
In Win2000/XP, the batch processing function (such as choice) is canceled, so the vbs script is replaced.
Sw. vbs
Dim stdin, stdout
Dim wshshell, oexec
Set stdin = wscript. stdin
Set stdout = wscript. stdout
Set wshshell = Createobject ("wscript. Shell ")
Stdout. writeline "Choice :"
Stdout. writeline "1: IP1"
Stdout. writeline "2: ip2"
Stdout. writeline "Other: Exit"

Do while not stdin. atendofstream
STR = stdin. Readline
If STR = "1" then
Stdout. writeline "Config IP1 network"
Wshshell. Exec ("netsh interface IP Set address local connection source = DHCP ")
Exit do
Elseif STR = "2" then
Stdout. writeline "Config ip2 network"
Wshshell. Exec ("netsh interface IP Set address local connection static 10.10.10.69 255.255.255.0 10.10.10.1 1 ")
Exit do
Else exit do
End if
Loop

Create netswitch. bat
Rem switch net between office and Research
Echo off
Cscript.exe Sw. vbs
Echo on

Netswitch. BAT and SW. to store vbs in the same folder, run netswitch. bat batch file. for details about netsh usage, refer to the Win2000/XP Help document. netsh also has many features. This article only uses the function of changing the IP address.

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.