yhshiro
初级用户
积分 130
发帖 59
注册 2007-12-25
状态 离线
|
『楼 主』:
VBS设置IP的问题
小弟不才。。想要一个自动设置IP的VBS脚本
我这有个设置IP的脚本。。。谁能帮我翻译一下,我想改点东西。。。
Dim IP,NetMask,Gateway,DNS1,DNS2,DNS3,DNS4,Name
cmpnmnum=3
DNS1="192.168.10.160"
DNS2="192.168.11.160"
DNS3="192.168.12.160"
DNS4="192.168.13.160"
inp=Inputbox ("请输入机号")
if (len(inp)<>(cmpnmnum+1)) then
msgbox("输入错误")
oShell.run "C:\s.vbs",0, false
wscript.quit
end if
area=left(inp,1)
area=UCase(area)
num=right(inp,cmpnmnum)
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("操作完成")
还有,为什么我输入几号后老是提示错误。。。。
谁帮我翻译一下哈。。。或者改改
|
|