strComputer="."
strmask="255.255.255.128"
dim ipv,gateway,lan,pcname
gateway="220.229.105.129"
ipv="220.229.105.123"
pcname="pc123"
Set objWMIService=GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters=objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress=Array(ipv)
strSubnetMask=Array(strmask)
strGateway = Array(gateway) '修改預設閘道
strDNS=Array("61.56.211.185","211.78.130.2","168.95.1.1") '// 三組 DNS
For Each objNetAdapter in colNetAdapters
errEnable=objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)'ip,子網路遮罩
errGateways = objNetAdapter.SetGateways(strGateway) '預設閘道
errDns=objNetAdapter.SetDNSServerSearchOrder(strDNS)'dns
Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
err = ObjComputer.Rename( pcname )'機器名稱
ReturnValue = objComputer.JoinDomainOrWorkGroup("WORKGROUP")'工作群組
Next