Win32_NetworkAdapterConfiguration return nothing RRS feed

  • Question

  • Hi,

    I have some VBscript that is used to test for network adapters.  It is fairly simple and works on most PCs.  On one PC, it returns nothing.  I am unsure as to what could be wrong.

    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: " & objItem.DefaultIPGateway
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "IPAddress: " & objItem.IPAddress
        Wscript.Echo "IPConnectionMetric: " & objItem.IPConnectionMetric
        Wscript.Echo "MACAddress: " & objItem.MACAddress
        Wscript.Echo "SettingID: " & objItem.SettingID



    Tuesday, December 8, 2015 6:54 PM


All replies

  • Remove On Error Resume Next and try again.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, December 8, 2015 6:58 PM
  • I know get an error.  Not sure what causes this.  Works on other PCs.  Research suggests that it is a syntax error, but shouldn't be if it works on other PCs.


    Tuesday, December 8, 2015 8:36 PM
  • Oops.  New error says Line: 4.  Bitmaps from older error message.  All other details identical.


    Tuesday, December 8, 2015 8:37 PM
  • What research have you done about this error?

    -- Bill Stewart [Bill_Stewart]

    Tuesday, December 8, 2015 9:09 PM
  • Have determined problem - Win32_NetworkAdapterConfiguration is missing from the PC that is having the issue (along with other WMI items).  Any idea on how to get WMI items to install?


    Tuesday, December 8, 2015 9:11 PM
  • Tuesday, December 8, 2015 9:12 PM
  • Does it work on the 'bad' machine if you run it in PowerShell?

    $colitems = Get-WmiObject Win32_NetworkAdapterConfiguration
    foreach ($colitem in $colitems) {
      Write-Host "DefaultIPGateway: $($colitem.DefaultIPGateway)"
      Write-Host "Description: $($colitem.Description)"
      Write-Host "IPAddress: $($colitem.IPaddress)"
      Write-Host "IPConnectionMetric: $($colitem.IPConnectionMetric)"
      Write-Host "MACAddress: $($colitem.MacAddress)"
      Write-Host "SettingID: $($colitem.SettingID)`n"

    . : | : . : | : . tim

    Tuesday, December 8, 2015 9:18 PM
  • You don't need $colitems or write-host at all to test in PowerShell. Just type

    PS C:\> Get-WmiObject Win32_NetworkAdapterConfiguration

    That's it.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, December 8, 2015 9:24 PM
  • Tried what Tim suggested.  Get the following:

    Not sure how to get around this.


    Tuesday, December 8, 2015 10:05 PM
  • WMI is broken on that computer.

    Take a look at the link Mike Laughlin posted.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, December 8, 2015 10:19 PM
  • Have run the utility on the problem PC.  There are a lot of problems with WMI.  It is recommending recompiling MOF files.  

    When I run the command 'wmidiag correlateclassandprovider' it gives lines like:

    ROOT/CIMV2, Win32_NetworkAdapterConfiguration, CIMWin32, In-proc, Instance Method, {D63A5850-8F16-11CF-9F47-00AA00BF345C}, NETWORKSERVICEHOST, , C:\WINDOWS\SYSTEM32\WBEM\CIMWIN32.DLL, C:\WINDOWS\SYSTEM32\WBEM\CIMWIN32.MOF / C:\WINDOWS\SYSTEM32\WBEM\SECRCW32.MOF

    This lists 2 mof's and a dll.  Do I need to run the MOFCOMP <FileName.MOF> on each mof and regsvr32 on the dll?


    Wednesday, December 9, 2015 3:24 PM
  • Please ask in the platform forum for your version of Windows. For example:

    -- Bill Stewart [Bill_Stewart]

    Wednesday, December 9, 2015 3:32 PM