运行VBScript枚举软件时出错:0x80041001



当我在windows8.1机器上运行VBScript时,我得到了以下错误。在其他计算机上成功运行了相同的代码。

Error: 0x80041001
Code: 80041001
Source: (null)
The error line is 'For each ...'

代码:

'obtain collection of Windows Installer packages
Set MSIapps = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & Computer & "rootcimv2").ExecQuery("select * from Win32_Product where Name like 'Cisco%'")
'enumerate the names of the packages in the collection
For each App in MSIapps 
    version =  App.Version
    installDIR = App.InstallLocation

Next

理论上,通过启动和停止WMI服务:

WMI作为显示名称为"Windows Management"的服务运行Instrumentation"和服务名称"winmgmt"。WMI运行在LocalSystem帐户下的系统启动时自动执行。如果WMI未运行,它在第一次管理时自动启动应用程序或脚本请求连接到WMI命名空间。

您的winmgmt服务似乎由于某种原因已停止工作。在命令提示符下(以管理员身份运行),输入net start winmgmt并查看输出消息。

将服务配置为使用services.msc自动运行,或者按照ChangYin对WMI损坏的回答-如何重新安装/修复?。

最新更新