在相同的计算机上查询WMI时出现错误80041017。 (Win32_PerfFormattedData_PerfOS_Memory)

时间:2018-01-26 18:00:22

标签: windows vbscript wmi windows-7-x64 wmi-query

为什么我收到错误:

  

代码:80041017
  资料来源:( null)

在这一行:

For Each oItem In colItems

在这个VBScript中:

strComputer = "."

Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
           & strComputer & "\root\cimv2")
Set cItems = oWMI.ExecQuery("Select * from Win32_PerfFormattedData_PerfOS_Memory")
'wsh.echo cItems.Count

Display "Win32_PerfFormattedData_PerfOS_Memory", FillCol(cItems)

function FillCol(colItems)
  Dim oItem, oProp, s

  For Each oItem In colItems
    For Each oProp In oItem.Properties_
      s =  s & oProp.Name & vbcrlf
      's =  s & oProp.Name & vbtab & oProp.Value & vbcrlf
    Next 'oProp
    Exit For
  Next 'oItem

  FillCol = s
End Function 'FillCol

Sub Display(sTitle, s)
  'Display results in a scrollable window
  height = 600 : width = 800
  Set oIE = CreateObject("InternetExplorer.Application")
  With oIE
    .RegisterAsDropTarget = False
    .Toolbar = False : menubar = False : statusbar = False
    .Width = Width : .Height = Height
    .Navigate "about:blank"
    Do Until .ReadyState = 4 : WScript.Sleep 50 : Loop
    With .Document
      .Open
      .Write  "<xmp>" & s & "</xmp>"
      .Close
      .Title = sTitle
    End With
    .Visible = True
  End With 'oIE
End Sub

直接从this link拍摄,但我改变了:

Win32_PrinterConfiguration

要:

Win32_PerfFormattedData_PerfOS_Memory

仅具有相同操作系统的两个64位工作站中的一个(Windows 7,都具有当前更新)和相同的硬件规格。计算机几乎完全相同,只有一个产生错误。

我已尝试this fix来修复损坏的WMI数据库:

但是当我使用时:

Win32_PrinterConfiguration

而不是:

Win32_PerfFormattedData_PerfOS_Memory

我没有收到错误。

发生了什么事?我需要做什么才能使该脚本在导致错误的工作站上工作?

EDIT1:我很确定错误实际上是由null返回值引起的。如果是这样,为什么RAM有空值?那应该是。正确?

EDIT2:请评论有关尝试或猜测的事情。

EDIT3:WMI诊断工具(https://www.microsoft.com/en-us/download/details.aspx?id=7684)说明了这一点:

28944 14:15:48 (1) !! ERROR: WMI GET operation errors reported: ........................................................................... 118 ERROR(S)! 28945 14:15:48 (0) ** - Root/CIMV2, Win32_PerfFormattedData_Counters_HTTPServiceRequestQueues, 0x0 - . 28946 14:15:48 (0) ** MOF Registration: 'WMI information not available (This could be the case for an external application or a third party WMI provider)' 28947 14:15:48 (0) ** - Root/CIMV2, Win32_PerfRawData_Counters_HTTPServiceRequestQueues, 0x0 - . 28948 14:15:48 (0) ** MOF Registration: 'WMI information not available (This could be the case for an external application or a third party WMI provider)' 28949 14:15:48 (0) ** - Root/CIMV2, Win32_PerfFormattedData_Counters_HTTPServiceUrlGroups, 0x0 - . 28950 14:15:48 (0) ** MOF Registration: 'WMI information not available (This could be the case for an external application or a third party WMI provider)' 28951 14:15:48 (0) ** - Root/CIMV2, Win32_PerfRawData_Counters_HTTPServiceUrlGroups, 0x0 - . 28952 14:15:48 (0) ** MOF Registration: 'WMI information not available (This could be the case for an external application or a third party WMI provider)'

...等...

29069 14:15:48 (0) ** - Root/CIMV2, Win32_PerfFormattedData_PerfOS_Memory, 0x0 - . 29070 14:15:48 (0) ** MOF Registration: 'WMI information not available (This could be the case for an external application or a third party WMI provider)'

...等...

不知道该怎么办。

EDIT4:看看这个修复:

  

您好,

     

请尝试以下问题排查建议来检查   结果:

     

Regsvr32%SystemRoot%\ System32 \ wbem \ wmidcprv.dll

     

cd / d%windir%\ system32 \ wbem

     对于(* .dll)中的%i,

执行RegSvr32 -s%i

     

表示(* .exe)中的%i执行%i / RegServer

     

可能会出现Windows Management Instrumentation Tester窗口   是正常的,我们可以继续关闭它。

     

如果它不起作用,我还建议你运行以下命令   修复WMI名称空间:

     

net stop winmgmt

     

wmic / NAMESPACE:\ root path“__namespace.name ='wmi'”delete

     

mofcomp%windir%\ system32 \ wbem \ wmi.mof

     

net start winmgmt

     

之后,请重新启动计算机以检查结果。如果   问题仍然存在,请尝试以下步骤:

     
      
  1. 单击“开始”按钮,“所有程序”,“附件”

  2.   
  3. 右键单击“命令提示符”并选择“以管理员身份运行”,接受UAC提示。

  4.   
  5. 在命令提示符下,键入以下命令,然后按Enter键。请每次输入一个命令。

  6.         

    winmgmt / verifyrepository

         

    winmgmt / salvagerepository

         

    此致

         

    Arthur Li

自: https://social.technet.microsoft.com/Forums/windows/en-US/df00b2e4-3bab-4b46-ad5a-95e82617a039/wmi-errors?forum=winserverNIS

1 个答案:

答案 0 :(得分:1)

重新加载效果计数器:

cd %windir%\system32\
lodctr /R
cd %windir%\sysWOW64\
lodctr /R

在这里找到: https://support.solarwinds.com/Success_Center/Server_Application_Monitor_(SAM)/Performance_counters_are_not_working_or_missing_in_PerfMon

请注意,上面的解决方案是我做的最后一件事&#34;解决了#34;问题;但是,我先从这个链接做了很多东西: https://kb.paessler.com/en/topic/3713-i-have-tried-a-lot-of-things-to-fix-my-wmi-what-else-can-i-try-to-avoid-reinstalling-windows?utm_source=google&utm_medium=cpc&utm_campaign=USA_EN_DSA_KB_Pages&utm_adgroup=USA_EN_DSA_KB&utm_adnum=dsa_en_04&utm_campaignid=657889421&utm_adgroupid=34407076718&utm_targetid=dsa-256625615450&utm_customerid=779-315-3659&utm_location=9028770&gclid=EAIaIQobChMI_8zX88KP2QIVVQOGCh2S-gIMEAAYASAAEgIZtvD_BwE

不确定我所做的事情的组合是解决了它还是我作为答案的4个命令解决了它。我所知道的是它现在正在运作!