VBS 改 IP(modify IP by VBS)

来源:互联网 发布:网络打印共享器怎么用 编辑:程序博客网 时间:2024/04/26 04:40
Set objShell = CreateObject("Wscript.Shell")
Dim strComputer, objWMIService, colNetAdapters, strIPAddress, strSubnetMask, errEnable, objNetAdapter


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
Set colNetAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")


strIPAddress = Array("192.168.1.26")
strSubnetMask = Array("255.255.254.0")


For Each objNetAdapter in colNetAdapters
 errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
 If errEnable = 0 Then
  msgbox "successful setting IP."
 Else
  msgbox "Failed to set IP."
 End if
Next
0 0