Automatically modify IP settings with scripts

xiaoxiao2021-03-06  64

Http://www.waynedeng.com/blog/showlog.asp?log_id=485&cat_id=26vbs script features very powerful, management system is simple and convenient! The following scripts will be used by Win2000 and WinXP, and Win2003 has not been tested and there should be no problem. This script is most convenient if you need to switch the gateway, or IP. Slightly modified or even 1 minute change IP.

Changeip.vbsstrComputer = "."

Set objwmiservice = getObject ("WinMgmts: //" & strComputer & "/ root / cimv2")

Set colnetadapters = Objwmiservice.execQuery_

("Select * from win32_networkadapterconfiguration where ienetabled = true")

For Each ObjNetadapter in colnetadapters

SIP = ObjNetAdapter.IPAddress

Stripaddress = SIP 'keeps the original IP, if you need to modify IP 192.168.0.200:StripAddress = Array ("192.168.0.200")

STRSUBNETMASK = Array ("255.255.255.0")

STRGATEWAY = Array ("192.168.0.254") 'Modify Gateway is 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 Not Be Changd."

END IF

EXIT for 'only modify the first network card setting

NEXT

转载请注明原文地址:https://www.9cbs.com/read-85426.html

New Post(0)