|
resetting LAN connection metric
I have been using the following vbscript to reset the connection metric on my
LAN. I am having problems getting it to work in Vista. Everthing seems to run
correctly but the value is not reset (when I look at the properties of the
Local Area Connection / properities of the TCPIP and Advanced). Also if I
rerun this script the value remains the same and is not the value I am
setting it to. I am running from an admin command prompt. I am guessing the
addition of IPv6 may have added new variables and the setipconnectionmetric
may have been renamed? Any ideas?
--------------------
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
regValueDataMetric = "35"
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapter Where NetConnectionID = 'Local Area
Connection'")
For Each objItem in colItems
strMACAddress = objItem.MACAddress
Wscript.Echo "MACAddress: " & strMACAddress
Next
Set colNetCard = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetCard in colNetCard
If objNetCard.MACAddress = strMACAddress Then
For Each strIPAddress in objNetCard.IPAddress
Wscript.Echo "Description: " & objNetCard.Description
Wscript.Echo "IP Address: " & strIPAddress
Wscript.Echo "IPConnectionMetric: " & objNetCard.IPConnectionMetric
objNetCard.SetIPConnectionMetric(regValueDataMetri c)
Next
End If
Next
|