VBS script is very powerful, easy management system! The following script Win2000 and WinXP can be used, WIN2003 has not been tested, there should be no problem. This script is most convenient if you need to switch gateways, or IP, frequently. A little modification can even be done in 1 minutes to change IP.
Changeip.vbsstrcomputer = "."
Set objWMIService = GetObject ("winmgmts:" & StrComputer & "Ootcimv2")
Set Colnetadapters = objWMIService.ExecQuery _
("SELECT * from Win32_NetworkAdapterConfiguration where ipenabled=true")
For each objnetadapter in Colnetadapters
Sip=objnetadapter.ipaddress
strIPAddress = Sip ' keeps the original IP if necessary to modify IP as 192.168.0.200:stripaddress = Array ("192.168.0.200")
Strsubnetmask = Array ("255.255.255.0")
Strgateway = Array ("192.168.0.254") ' Modify gateway to 192.168.0.254
Strgatewaymetric = Array (1)
errenable = Objnetadapter.enablestatic (stripaddress, Strsubnetmask)
Errgateways = Objnetadapter.setgateways (Strgateway, Strgatewaymetric)
If errenable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could is not changed."
End If
Exit for ' only modifies the first network adapter settings
Next
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.