[VBS脚本]关于自动填写IP地址,子网掩码,网关,DNS!

这个脚本,想去掉那个填写机器号的框直接更改指定IP、网关... ...

还需要一个`自动获取IP地址 和自动获取DNS的``脚本!!!

新手...只有这些分儿...实在对不住大家了!!

请哪位师兄指点一下!!!谢谢!!!!!!!!!!!!!!!!!!!!

Dim Num
Num=Inputbox ("程序员:youngye"+chr(10)&chr(13)+"QQ:355430413"+chr(10)&chr(13)+"必须是小于200以下的数字"+chr(10)&chr(13)+"请输入机器号","杨铄工作室")
dim Name
if Num<10 then
Name="XD00"
else
if Num<100 then
Name="XD0"
else
Name="XD"
end if
end if

Set Sh = CreateObject("WScript.Shell")
Sh.RegWrite "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName",Name&Num,"REG_SZ"
Sh.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname",Name&Num,"REG_SZ"
Sh.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname",Name&Num,"REG_SZ"
Set sh = Nothing
Set oShell = Nothing
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("192.168.1."&Num)
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.1")
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway)

Dim dns
dns=Array("211.93.80.129","211.94.33.193")
err=objNetAdapter.SetDNSServerSearchOrder(dns)
'msgbox(err)

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("game" &Num)
Next
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIPXVirtualNetworkNumber(Num)
最新回答
爱过方知情重

2024-06-25 10:57:47

把下面这一段取消,
Dim Num
Num=Inputbox ("程序员:youngye"+chr(10)&chr(13)+"QQ:355430413"+chr(10)&chr(13)+"必须是小于200以下的数字"+chr(10)&chr(13)+"请输入机器号","杨铄工作室")
dim Name
if Num<10 then
Name="XD00"
else
if Num<100 then
Name="XD0"
else
Name="XD"
end if
end if

改写成
Name=XD00
就可以了。
七米海岸

2024-06-25 06:02:48

在里面添一句
sh.run "cmd /k ipconfig /all|find /i "&chr(34)&"dns servers"&chr(34)&""