Skip to content
This repository was archived by the owner on Jan 22, 2022. It is now read-only.
This repository was archived by the owner on Jan 22, 2022. It is now read-only.

Invalid class when querying Win32_Process #50

@kongslund

Description

@kongslund

As part of troubleshooting an issue encountered with wmi_exporter, I tried running the provided code example which queries Win32_Process:

package main

import (
	"github.com/StackExchange/wmi"
	"log"
)

type Win32_Process struct {
	Name string
}

func main() {
	var dst []Win32_Process
	q := wmi.CreateQuery(&dst, "")
	err := wmi.Query(q, &dst)
	if err != nil {
		log.Fatal(err)
	}
	for i, v := range dst {
		println(i, v.Name)
	}
}

It fails on an instance of Windows Server 2012 Standard, 64-bit with the following error:

2019/09/05 10:32:37 Exception occurred. (Invalid class )

However the following PowerShell snippet works:

Get-WmiObject -Query "SELECT Name FROM Win32_Process"

The output looks like:

__GENUS          : 2
__CLASS          : Win32_Process
__SUPERCLASS     :
__DYNASTY        :
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
Name             : System Idle Process
PSComputerName   :
...

In addition, if I run

winmgmt /verifyrepository

the result is

WMI repository is consistent

Also, if I run wmimgmt.msc and open the properties for WMI Control (Local), no errors are shown.

Any ideas of how to proceed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions