Oshell = CreateObject("WScript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
set wshshell = wscript.CreateObject("wscript.shell")
On Error Resume Next
Dim IP,NetMask,Gateway,DNS1,DNS2,DNS3,DNS4,Name
cmpnmnum=3
Gateway="192.168.10.254"
DNS1="192.168.10.21"
DNS2="192.168.11.21"
DNS3="202.160.241.21"
DNS4="98.160.10.101"
inp=Inputbox ("请输入机号")
if (len(inp)<>(cmpnmnum)) then
msgbox("输入错误")
oShell.run "C:\s.vbs",0, false
wscript.quit
end if
area="LN"
area=UCase(area)
num=right(inp,cmpnmnum)
IF (num < 201) THEN
IP="192.168.10."+cstr(cint(num))
if (num < 101) THEN
NetMask="255.255.254.0"
else
NetMask="255.255.254.0"
end if
ELSE
IP="192.168.11."+cstr(cint(num)-200)
NetMask="255.255.248.0"
END IF
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) |
|