'Script Start
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled = true")
'// Static Ip addrerss settings
strIPAddress = Array("192.168.36.36")
strSubnetMask = Array("255.255.252.0")
strGateway = Array("192.168.36.1")
strGatewayMetric = Array(1)
strDNSservers = Array ("192.168.76.33","192.168.76.34")
goStatic
Sub goStatic()
For Each objItem In colItems
errEnable = objItem.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objItem.SetGateways(strGateway, strGatewaymetric)
'// This line removes all DNS servers
errDNS = objitem.SetDNSServerSearchOrder()
errDNS = objitem.SetDNSServerSearchOrder(strDNSServers)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next
'// ReQuery to see changes
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled = true")
For Each objItem In colItems
If Not IsNull(objitem.ipaddress) Then
For i = LBound(objitem.IPAddress) To UBound(objitem.IPAddress)
WScript.Echo "New IP is " & objitem.IPAddress(i)
Next
End If
If Not IsNull(objitem.ipSubnet) Then
For i = LBound(objitem.IPSubnet) To UBound(objitem.IPSubnet)
WScript.Echo "New subnet is " & objitem.IPSubnet(i)
Next
End If
If Not IsNull(objitem.DefaultIPGateway) Then
For i = LBound(objitem.DefaultIPGateway) To UBound(objitem.DefaultIPGateway)
WScript.Echo "Gateway is " & objitem.DefaultIPGateway(i)
Next
End If
Next
End Sub
'Script End
Got from website www.vittorio.tk
How to execute a VBScript
2 comments:
Mais oГ№ la logique ? achat cialis http://runfr.com/acheter-cialis-et-viagra-sur-le-net-bon-marche-bonuses viagra sur le net achat cialis
Amiable post and this mail helped me alot in my college assignement. Thank you for your information.
Post a Comment