I have seen this code (I think written by marcdmac). Is there a way to pull the network adapter name (ie. "Local Area Connection" or "Wireless Connection") from within the For loop?
Thanks,
Andrew
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
userInput = InputBox ("Enter IP Address:", "IP Address Change")
strIPAddress = Array(userInput)
strSubnetMask = Array("255.255.0.0")
strGateway = Array("150.142.x.x")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
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
Thanks,
Andrew