【发布时间】:2018-01-26 18:00:22
【问题描述】:
为什么会出错:
代码:80041017
来源:(空)
在这一行:
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
仅在具有相同操作系统(Windows 7,均具有最新更新)和相同硬件规格的两个 64 位工作站中的一个上。两台电脑几乎一模一样,只有一台会出错。
我已尝试this fix 修复损坏的 WMI 数据库:
但是当我使用时:
Win32_PrinterConfiguration
代替:
Win32_PerfFormattedData_PerfOS_Memory
我没有收到错误消息。
发生了什么事?我需要做什么才能让该脚本在导致错误的工作站上运行?
EDIT1:我很确定错误实际上是由空返回值引起的。如果是这样,为什么 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
for %i in (*.dll) do RegSvr32 -s %i
对于 (*.exe) 中的 %i 执行 %i /RegServer
可能会出现 Windows Management Instrumentation Tester 窗口,这 是正常的,我们可以继续关闭它。
如果还是不行,我还建议你运行以下命令 修复 WMI 命名空间:
net stop winmgmt
wmic /NAMESPACE:\root path "__namespace.name='wmi'" 删除
mofcomp %windir%\system32\wbem\wmi.mof
net start winmgmt
之后,请重新启动计算机以查看结果。如果 问题依旧,请尝试以下步骤:
点击开始按钮、所有程序、附件
右击“命令提示符”,选择“以管理员身份运行”,接受UAC提示。
在命令提示符下,键入以下命令并按 Enter。请每次输入一个命令。
winmgmt /verifyrepository
winmgmt /salvagerepository
问候,
李亚瑟
【问题讨论】:
-
欢迎来到 WMI 的不一致世界。
-
听起来你有这方面的经验。您过去是如何解决的?
-
老实说,我从来没有找到解决方案,最后不得不重建有问题的电脑,即使那样也不能保证它会工作。如果 WMI 决定它不喜欢硬件方面的某些东西,那么您就无能为力了。
标签: windows vbscript wmi windows-7-x64 wmi-query