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.