我第一次运行this example C++ code from MSDN从远程计算机获取WMI数据时,它工作正常 . 它也适用于与我相同配置的同事: Windows Server 2008 R2 Virtual Machine (域控制器)作为远程机器; Windows 7 host machine (在不同的域中)作为进行呼叫的客户端 .

但是,在某些时候,代码停止工作 . 代码的简要概述:它提示输入凭据,然后连接到远程服务器,然后使用WQL行查询其OS信息 Select * from win32_operatingsystem ,然后检索返回的OS对象,然后请求表示操作系统名称和对象的对象表示机器上的空闲内存,将此信息打印到控制台 . 它在第一次 IEnumWbemClassObject::Next 调用时出现错误,该调用应检索OS对象 .

我目前使用的代码是上面链接的示例代码的略微改编版本 . 这里是.cpp的全部内容(删除了一些注释掉的代码块):

#define _WIN32_DCOM
#define UNICODE
#include <iostream>
using namespace std;
#include <comdef.h>
#include <Wbemidl.h>
#pragma comment(lib, "wbemuuid.lib")
#pragma comment(lib, "credui.lib")
#pragma comment(lib, "comsuppw.lib")
#include <wincred.h>
#include <strsafe.h>

// Macro for cleanup (changed to exit to imitate original code more closely)
#define EXIT(x) { ret = x; goto out; }

// Entry point:
int __cdecl main(int argc, char **argv)
{
    HRESULT hres;
    int ret = 0;

    // Initialize COM
    hres = CoInitializeEx(0, COINIT_MULTITHREADED); 
    if (FAILED(hres))
    {
        cout << "Failed to initialize COM library. Error code = 0x" << hex << hres << endl;
        EXIT(1);
    }

    // Set general COM security levels
    hres =  CoInitializeSecurity(
        NULL, 
        -1,                          // COM authentication
        NULL,                        // Authentication services
        NULL,                        // Reserved
        RPC_C_AUTHN_LEVEL_DEFAULT,   // Default authentication 
        RPC_C_IMP_LEVEL_IDENTIFY,    // Default Impersonation  
        NULL,                        // Authentication info
        EOAC_NONE,                   // Additional capabilities 
        NULL                         // Reserved
        );

    if (FAILED(hres))
    {
        cout << "Failed to initialize security. Error code = 0x" << hex << hres << endl;
        CoUninitialize();
        EXIT(1);
    }

    // Obtain the initial locator to WMI 
    IWbemLocator* pLoc = NULL;
    hres = CoCreateInstance(
        CLSID_WbemLocator,             
        0, 
        CLSCTX_INPROC_SERVER, 
        IID_IWbemLocator, 
        (LPVOID*)&pLoc); 

    if (FAILED(hres))
    {
        cout << "Failed to create IWbemLocator object." << hex << hres << endl;
        CoUninitialize();
        EXIT(1);
    }

    // Connect to WMI through the IWbemLocator::ConnectServer method...
    IWbemServices* pSvc = NULL;

    // First, prompt for the user name and password for the remote computer
    CREDUI_INFO cui;
    bool useToken = false;
    bool useNTLM = true;
    wchar_t pszName[CREDUI_MAX_USERNAME_LENGTH+1] = {0};
    wchar_t pszPwd[CREDUI_MAX_PASSWORD_LENGTH+1] = {0};
    wchar_t pszDomain[CREDUI_MAX_USERNAME_LENGTH+1];
    wchar_t pszUserName[CREDUI_MAX_USERNAME_LENGTH+1];
    wchar_t pszAuthority[CREDUI_MAX_USERNAME_LENGTH+1];
    BOOL fSave;
    DWORD dwErr;

    memset(&cui,0,sizeof(CREDUI_INFO));
    cui.cbSize = sizeof(CREDUI_INFO);
    cui.hwndParent = NULL;

    cui.pszMessageText = TEXT("Press cancel to use process token");
    cui.pszCaptionText = TEXT("Enter Account Information");
    cui.hbmBanner = NULL;
    fSave = FALSE;

    dwErr = CredUIPromptForCredentials( 
        &cui,                             // CREDUI_INFO structure
        TEXT(""),                         // Target for credentials
        NULL,                             // Reserved
        0,                                // Reason
        pszName,                          // User name
        CREDUI_MAX_USERNAME_LENGTH+1,     // Max number for user name
        pszPwd,                           // Password
        CREDUI_MAX_PASSWORD_LENGTH+1,     // Max number for password
        &fSave,                           // State of save check box
        CREDUI_FLAGS_GENERIC_CREDENTIALS |// flags
        CREDUI_FLAGS_ALWAYS_SHOW_UI |
        CREDUI_FLAGS_DO_NOT_PERSIST);  

    if (ERROR_CANCELLED == dwErr)
    {
        useToken = true;
    }
    else if (dwErr)
    {
        cout << "Did not get credentials: " << dwErr << endl;
        pLoc->Release();
        CoUninitialize();
        EXIT(1);  
    }

    if (!useNTLM)
    {
        cout << "not using NTLM" << endl;
        StringCchPrintf(pszAuthority, CREDUI_MAX_USERNAME_LENGTH+1, L"kERBEROS: %s", L"serverdude");
    }

    // Connect to the remote root\cimv2 namespace and obtain pointer pSvc to make IWbemServices calls.
    hres = pLoc->ConnectServer(
        _bstr_t(L"\\\\serverdude\\root\\cimv2"),
        _bstr_t(useToken?NULL:pszName),    // User name
        _bstr_t(useToken?NULL:pszPwd),     // User password
        NULL,                              // Locale             
        NULL,                              // Security flags
        _bstr_t(useNTLM?NULL:pszAuthority),// Authority        
        NULL,                              // Context object
        &pSvc                              // IWbemServices proxy
        );

    if (FAILED(hres))
    {
        cout << "Could not connect. Error code = 0x" << hex << hres << endl;
        pLoc->Release();
        CoUninitialize();
        EXIT(1);
    }
    cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;

    // Create COAUTHIDENTITY that can be used for setting security on proxy
    COAUTHIDENTITY* userAcct = NULL;
    COAUTHIDENTITY authIdent;

    if (!useToken)
    {
        memset(&authIdent, 0, sizeof(COAUTHIDENTITY));
        authIdent.PasswordLength = wcslen (pszPwd);
        authIdent.Password = (USHORT*)pszPwd;

        LPWSTR slash = wcschr (pszName, L'\\');
        if (NULL == slash)
        {
            cout << "Could not create Auth identity. No domain specified.\n";
            pSvc->Release();
            pLoc->Release();
            CoUninitialize();
            EXIT(1);
        }

        StringCchCopy(pszUserName, CREDUI_MAX_USERNAME_LENGTH+1, slash+1);
        authIdent.User = (USHORT*)pszUserName;
        authIdent.UserLength = wcslen(pszUserName);

        StringCchCopyN(pszDomain, CREDUI_MAX_USERNAME_LENGTH+1, pszName, slash - pszName);
        authIdent.Domain = (USHORT*)pszDomain;
        authIdent.DomainLength = slash - pszName;
        authIdent.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;

        userAcct = &authIdent;
    }

    // Set security levels on a WMI connection
    hres = CoSetProxyBlanket(
       pSvc,                           // Indicates the proxy to set
       RPC_C_AUTHN_DEFAULT,            // RPC_C_AUTHN_xxx
       RPC_C_AUTHZ_DEFAULT,            // RPC_C_AUTHZ_xxx
       COLE_DEFAULT_PRINCIPAL,         // Server principal name 
       RPC_C_AUTHN_LEVEL_PKT_PRIVACY,  // RPC_C_AUTHN_LEVEL_xxx 
       RPC_C_IMP_LEVEL_IMPERSONATE,    // RPC_C_IMP_LEVEL_xxx
       userAcct,                       // client identity
       EOAC_NONE                       // proxy capabilities 
    );

    if (FAILED(hres))
    {
        cout << "Could not set proxy blanket. Error code = 0x" << hex << hres << endl;
        pSvc->Release();
        pLoc->Release();
        CoUninitialize();
        EXIT(1);
    }

    // Use the IWbemServices pointer to make requests of WMI...
    // Get the name of the operating system
    IEnumWbemClassObject* pEnum = NULL;
    hres = pSvc->ExecQuery(
        bstr_t("WQL"), 
        bstr_t("Select * from Win32_OperatingSystem"),
        WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 
        NULL,
        &pEnum);

    if (FAILED(hres))
    {
        cout << "Query for operating system name failed." << " Error code = 0x" << hex << hres << endl;
        pSvc->Release();
        pLoc->Release();
        CoUninitialize();
        EXIT(1);
    }

    // Secure the enumerator proxy
    hres = CoSetProxyBlanket(
        pEnum,                          // Indicates the proxy to set
        RPC_C_AUTHN_DEFAULT,            // RPC_C_AUTHN_xxx
        RPC_C_AUTHZ_DEFAULT,            // RPC_C_AUTHZ_xxx
        COLE_DEFAULT_PRINCIPAL,         // Server principal name 
        RPC_C_AUTHN_LEVEL_PKT_PRIVACY,  // RPC_C_AUTHN_LEVEL_xxx 
        RPC_C_IMP_LEVEL_IMPERSONATE,    // RPC_C_IMP_LEVEL_xxx
        userAcct,                       // client identity
        EOAC_NONE                       // proxy capabilities 
        );

    if (FAILED(hres))
    {
        cout << "Could not set proxy blanket on enumerator. Error code = 0x" << hex << hres << endl;
        pEnum->Release();
        pSvc->Release();
        pLoc->Release();
        CoUninitialize();
        EXIT(1);
    }

    // Erase credentials from memory.
    SecureZeroMemory(pszName, sizeof(pszName));
    SecureZeroMemory(pszPwd, sizeof(pszPwd));
    SecureZeroMemory(pszUserName, sizeof(pszUserName));
    SecureZeroMemory(pszDomain, sizeof(pszDomain));

    // Get the data from the OS query
    IWbemClassObject* pclsObj = NULL;
    ULONG uReturn = 0;

    while (pEnum)
    {
        // DEBUG:
        cout << "beginning of loop..." << endl;

        // Get the result of the query
        HRESULT hr = pEnum->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);  

        // DEBUG:
        cout << "IEnumWbemClassObject::Next returned 0x" << hex << hr << endl;

        // PATCH: NOT SURE WHY IT WORKS
        if (0 == uReturn)
        {
            continue;
        }

        // Get the value of the Name property
        VARIANT vtProp;
        hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
        if (FAILED(hr))
        {
            cout << "Could not get OS name. Error code = 0x" << hex << hr << endl;
            EXIT(1);
        }

        // Display OS name info
        wcout << "\tOS Name : " << vtProp.bstrVal << endl;

        // Get the value of the FreePhysicalMemory property
        hr = pclsObj->Get(L"FreePhysicalMemory", 0, &vtProp, 0, 0);
        if (FAILED(hr))
        {
            cout << "Could not get free physical memory. Error code = 0x" << hex << hr << endl;
            EXIT(1);
        }

        // Display free memory info
        wcout << "\tFree physical memory (in kilobytes): " << vtProp.uintVal << endl;

        VariantClear(&vtProp);
        pclsObj->Release();
        pclsObj = NULL;

        // KEEP THIS ONLY IF USING PATCH SOLN
        break;
    }

    // Clean up
    pSvc->Release();
    pLoc->Release();
    pEnum->Release();
    if (pclsObj) 
    { 
        pclsObj->Release(); 
    }
    CoUninitialize(); 

out:
    system("pause");
    return ret;
}

控制台的输出是:

Connected to ROOT\CIMV2 WMI namespace
beginning of loop...
IEnumWbemClassObject::Next returned 0x800706bf
beginning of loop...
IEnumWbemClassObject::Next returned 0x0
        OS Name : Microsoft Windows Server 2008 R2 Datacenter |C:\Windows|\Device\Harddisk0\Partition1
        Free physical memory (in kilobytes): 8050116
Press any key to continue . . .

对代码的唯一重大改变是最后的循环 . 如果 EnumWbemClassObject::NextpuReturned 参数设置为0(请求的1的indicating 0 objects returned),则MSDN示例不会检查错误,而是会中断循环 . 相反,我显示结果但不对其进行操作,如果 uResult 为0则再次尝试循环,并且只有在没有't. This is obviously a hacky solution that could result in an infinite loop if the code worked properly. It'时才会跳出循环也值得注意的是,当我在尝试循环时,我得到了一个奇怪的访问违规:程序在某一行抛出异常,但当我改变下一行时,问题就消失了 . 这让我觉得内存损坏可能会有些奇怪 .

这是更奇怪的部分:当我运行 WBEMtest.exe (Windows提供的用于运行本地或远程WMI命令的GUI)时, my query also only works on the second try . 像我的代码一样,它在第一次尝试时返回 Error 0x800706bf: The remote procedure call failed and did not execute .

出于好奇,我使用事件记录记录了WMI活动 . 我无法从结果中收集到太多信息(除了我的代码和WBEMtest.exe之间发生了不同的事情),但无论如何它们都在这里:

从我的代码运行:

Level   Date and Time   Source  Event ID    Task Category
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6350; OperationId = 6350; Operation = IWbemServices::Connect; ClientMachine = MSJOHNSON-THINK; User = CORP\Administrator; ClientProcessId = 26304; NamespaceName = \\serverdude\root\cimv2
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6351; OperationId = 6352; Operation = Start IWbemServices::ExecQuery - Select * from Win32_OperatingSystem; ClientMachine = MSJOHNSON-THINK; User = CORP\Administrator; ClientProcessId = 26304; NamespaceName = \\.\root\cimv2
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6351; OperationId = 6353; Operation = Start IWbemServices::ExecQuery - Select * from __ClassProviderRegistration; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6354; Operation = Start IWbemServices::GetObject - __Win32Provider.Name=""WmiPerfClass""; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6354
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6355; Operation = Start IWbemServices::ExecQuery - references of {__Win32Provider.Name=""WmiPerfClass""}; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6353
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6356; Operation = Start IWbemServices::GetObject - __Win32Provider.Name=""CIMWin32""; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6356
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6357; Operation = Start IWbemServices::ExecQuery - references of {__Win32Provider.Name=""CIMWin32""}; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6355
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6357
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6358; OperationId = 6358; Operation = IWbemServices::Connect; ClientMachine = WIN-T53A1FADTFB; User = NT AUTHORITY\NETWORK SERVICE; ClientProcessId = 3000; NamespaceName = Root
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6358
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6359; Operation = Start IWbemServices::ExecQuery - references of {__Win32Provider.Name=""CIMWin32""}; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6359
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6351; OperationId = 6360; Operation = Start IWbemServices::GetObject - Win32_OperatingSystem; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6360
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6361; Operation = Start IWbemServices::GetObject - __Win32Provider.Name=""CIMWin32""; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6361
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6362; Operation = Start IWbemServices::ExecQuery - references of {__Win32Provider.Name=""CIMWin32""}; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6362
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  2   None    ProviderInfo for GroupOperationId = 6351; Operation = Provider::CreateInstanceEnum - Win32_OperatingSystem; ProviderName = CIMWin32; ProviderGuid = {d63a5850-8f16-11cf-9f47-00aa00bf345c}; Path = %systemroot%\system32\wbem\cimwin32.dll
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6351; OperationId = 6363; Operation = Start IWbemServices::ExecQuery - SELECT __RELPATH FROM Win32_Process; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6364; Operation = Start IWbemServices::GetObject - __Win32Provider.Name=""CIMWin32""; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6364
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6365; Operation = Start IWbemServices::ExecQuery - references of {__Win32Provider.Name=""CIMWin32""}; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6365
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6351; OperationId = 6366; Operation = Start IWbemServices::GetObject - Win32_Process; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6366
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6367; Operation = Start IWbemServices::GetObject - __Win32Provider.Name=""CIMWin32""; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6367
Information 12/6/2012 12:22:03 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6351; OperationId = 6368; Operation = Start IWbemServices::ExecQuery - references of {__Win32Provider.Name=""CIMWin32""}; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName =

从运行WBEMtest.exe:

Level   Date and Time   Source  Event ID    Task Category
Information 12/6/2012 12:29:41 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6373; OperationId = 6373; Operation = IWbemServices::Connect; ClientMachine = MSJOHNSON-THINK; User = CORP\Administrator; ClientProcessId = 26004; NamespaceName = \\serverdude\root\cimv2
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6374; OperationId = 6375; Operation = Start IWbemServices::ExecQuery - select * from win32_operatingsystem; ClientMachine = MSJOHNSON-THINK; User = CORP\Administrator; ClientProcessId = 26004; NamespaceName = \\.\root\cimv2
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6374; OperationId = 6376; Operation = Start IWbemServices::ExecQuery - Select * from __ClassProviderRegistration; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6374; OperationId = 6377; Operation = Start IWbemServices::GetObject - __Win32Provider.Name=""WmiPerfClass""; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6377
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  1   None    "GroupOperationId = 6374; OperationId = 6378; Operation = Start IWbemServices::ExecQuery - references of {__Win32Provider.Name=""WmiPerfClass""}; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2"
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6376
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6378
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6374; OperationId = 6379; Operation = Start IWbemServices::GetObject - win32_operatingsystem; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  3   None    Stop OperationId = 6379
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  2   None    ProviderInfo for GroupOperationId = 6374; Operation = Provider::CreateInstanceEnum - Win32_OperatingSystem; ProviderName = CIMWin32; ProviderGuid = {d63a5850-8f16-11cf-9f47-00aa00bf345c}; Path = %systemroot%\system32\wbem\cimwin32.dll
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6374; OperationId = 6380; Operation = Start IWbemServices::ExecQuery - SELECT __RELPATH FROM Win32_Process; ClientMachine = Local; User = CORP\Administrator; ClientProcessId = 0; NamespaceName = \\.\root\CIMV2
Information 12/6/2012 12:29:52 PM   Microsoft-Windows-WMI-Activity  1   None    GroupOperationId = 6374; OperationId = 6381; Operation = Start IWbemServices::GetObject - Win32_Process; ClientMachine = Local; User

所以,是的,我正在继续?我已经看到其他人在类似情况下的机器之间看到WMI行为不一致的报告(例如,这里称为Win32_BaseBoard的WMI查询的问题没有返回结果 - 可能't link because of the two-hyperlink max for new users), but I'从未见过令人满意的解释 . 顺便说一下,我开始使用新VM和仍然有这个问题(虽然每隔一段时间WBEMtest.exe没有在第一次尝试时出错) .