I need to retrieve default gateway network settings. The information is available in Win32_NetworkAdapterConfiguration. Scriptomatic produces the following relevant code.
-----------------
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48)
For Each objItem in colItems
Wscript.Echo "DefaultIPGateway: "
For Each objElement In objItem.DefaultIPGateway
WScript.Echo vbTab & objElement
Next
Next
-----------------
DefaultIPGateway appears to be a collection. This is confirmed by WMI Object Browser which indicates DefaultIPGateway is "array of string"
When I extract the code for use elsewhere, it does not work.
To investigate: I changed the first line of Scriptomatic to
on error GOTO 0
I get the following error message
C:\scriptomatic-network.vbs(7, 5) Microsoft VBScript runtime error: Object not a collection
Question:
Is DefaultIPGateway a collection or not?
Why does Scriptomatic produce errors?
Thanks for your help
-----------------
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48)
For Each objItem in colItems
Wscript.Echo "DefaultIPGateway: "
For Each objElement In objItem.DefaultIPGateway
WScript.Echo vbTab & objElement
Next
Next
-----------------
DefaultIPGateway appears to be a collection. This is confirmed by WMI Object Browser which indicates DefaultIPGateway is "array of string"
When I extract the code for use elsewhere, it does not work.
To investigate: I changed the first line of Scriptomatic to
on error GOTO 0
I get the following error message
C:\scriptomatic-network.vbs(7, 5) Microsoft VBScript runtime error: Object not a collection
Question:
Is DefaultIPGateway a collection or not?
Why does Scriptomatic produce errors?
Thanks for your help