无法通过 GETOBJECT("winmgmts:") 获取 WMI 对象 [英] Unable to get WMI object via GETOBJECT("winmgmts:" )

查看:28
本文介绍了无法通过 GETOBJECT("winmgmts:") 获取 WMI 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑,似乎找不到明确的答案.我正在尝试通过 WMI 获取网络适配器列表.我一直在使用的命令在我们办公室的几乎所有工作站上都​​运行良好,没有任何问题.昨天,问题.一台机器出故障.由于它直接在用户机器上运行,因此我不必明确放置他们的机器名称,因此只使用."对于本地机器.然后,我不在乎谁",所以也没有假冒.用户应该能够查询自己的设备资源.我使用的是...

I'm stumped and can't seem to find a definitive answer. I'm trying to get a list of network adapters via WMI. The command I've been using has been working fine for almost all the workstations in our office with no problem. Yesterday, problem. One machine fails out. Since its run directly on the users machine, I don't have to explicitly put their machine name and thus using just the "." for local machine. Then, I don't care about the "who", so there's no impersonation going on either. The user should be able to query their own equipment resources. What I WAS using was...

oWMIService = GETOBJECT("winmgmts:\\.\root\cimv2")
oItems = oWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)

根据我的发现,有些地方说要删除机器路径引用的\".如果我这样做,我的机器就会出现故障,在另一台有问题的机器上仍然没有结果.所以,我什至尝试过访问服务的根目录,但也失败了.

From what I've found, some places say to remove the "\" for the machine path reference. If I do that, MY machine fails, still no result on the other machine in question. So, I've even tried just going to the root for the service and THAT fails too.

oWMIService = GETOBJECT("winmgmts:\\.")

我得到的实际错误是...

The actual error I'm getting is...

Error Code: 0x800401ea: Moniker cannot open file.

我对这个名字错误做了一些搜索,但不知道如何解决.

I've done some searching on this moniker error, but don't know how to get resolution.

推荐答案

有时 WMI 会损坏和混淆.您可以尝试的选项是:

Sometimes WMI gets corrupted and confused. Options you could try are:

使用这样的批处理脚本重新注册/重新编译 WMI 组件:

Re-register/re-compile the WMI components with a batch script like this:

net stop winmgmt
cd /d %windir%\system32\wbem\
for %i in (*.dll) do RegSvr32 /s %i
for %i in (*.mof, *.mfl) do Mofcomp %i
net start winmgmt

如果这不能解决问题,请使用此批处理重置 WMI 数据库:

If that doesn't solve it, do a reset of the WMI database with this batch:

net stop winmgmt
cd /d %windir%\system32\wbem\
rmdir /s /q Repository
rmdir /s /q Logs
mkdir Logs
net start winmgmt

和/或尝试使用 WMIDiag 之类的工具.vbs 脚本,看看它是否对你有建议.

And/or try a tool like the WMIDiag.vbs script to see if it has suggestions for you.

这篇关于无法通过 GETOBJECT("winmgmts:") 获取 WMI 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆