Dim Num
Num=Inputbox ("请输入机器号"+chr(10)&chr(13)+""+chr(10)&chr(13)+"取值范围2-254的数字")
dim Name
if Num<10 then
Name="BX00"
else
if Num<100 then
Name="BX0"
else
Name="BX"
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"
Sh.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\VirtualNetworkNumber",Num,"REG_DWORD"
Sh.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NwlnkIpx\Parameters\VirtualNetworkNumber",Num,"REG_DWORD"
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.0."&Num)
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.0.1")
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway)
Dim dns
dns=Array("192.168.0.1","220.189.127.106")
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)
注意:蓝色字体部分请根据需要自行更改
