Posted August 6, 200619 yr Option ExplicitDim NetworkAdapter, AdapterConfiguration 'ObjectsDim IPAddress, SubnetMask, Gateway, DNS 'String ArraysDim RetVal 'IntegersFor Each NetworkAdapter InGetObject("winmgmts:").InstancesOf("Win32_NetworkAdapter") If NetworkAdapter.AdapterType = "Ethernet 802.3" Then For Each AdapterConfiguration In GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration") If UCase(AdapterConfiguration.ServiceName) = UCase(NetworkAdapter.ServiceName) Then IPAddress = Array("192.168.0.10") SubnetMask = Array("255.255.255.0") Gateway = Array("192.168.0.1") DNS = Array("35.8.2.41") RetVal = AdapterConfiguration.EnableStatic(IPAddress, SubnetMask) If Not RetVal = 0 Then WScript.Echo "Failure assigning IP/Subnetmask." End If RetVal = AdapterConfiguration.SetGateways(Gateway) If Not RetVal = 0 Then WScript.Echo "Failure assigning Gateway." End If RetVal = AdapterConfiguration.SetDnsServerSearchOrder(DNS) If Not RetVal = 0 Then WScript.Echo "Failure assinging DNS search order." End If End If Next End IfNext
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now