Select Case area
Case "A"
IP="192.168.10."+cstr(cint(num))
NetMask="255.255.255.0"
Gateway="192.168.10.254"
'oShell.run "C:\refresh.cmd 1024,768 85",0, true
Case "B"
IP="192.168.11."+cstr(cint(num))
NetMask="255.255.254.0"
Gateway="192.168.11.254"
'oShell.run "C:\refresh.cmd 1024,768 85",0, true
End Select
Name=area+cstr(num)
ipxz=1
for i = 1 to cmpnmnum
ipxz=ipxz*10
Next
IPX=asc(area)*ipxz+num
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array(IP)
strSubnetMask = Array(NetMask)
strGateway = Array(Gateway)
strDNS = Array(DNS1,DNS2,DNS3,DNS4)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
errDNS = objNetAdapter.SetDNSServerSearchOrder(strDNS)
Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
ObjComputer.Rename(Name)
Next
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIPXVirtualNetworkNumber(IPX)
msgbox("操作完成")