Error: 0x80041001 when running VBScript to enumerate software

0

When I ran a VBScript on a windows8.1 machine, I got the following error. Same code ran successfully on other machines.

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

Code:

'obtain collection of Windows Installer packages

Set MSIapps = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2").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
windows
vbscript
asked on Stack Overflow Mar 31, 2015 by David • edited Mar 31, 2015 by SiKing

1 Answer

0

In theory, by Starting and Stopping the WMI Service:

WMI runs as a service with the display name "Windows Management Instrumentation" and the service name "winmgmt". WMI runs automatically at system startup under the LocalSystem account. If WMI is not running, it automatically starts when the first management application or script requests connection to a WMI namespace.

Looks like your winmgmt service has stopped working for some reason. At a command prompt (run as administrator), enter net start winmgmt and watch output message.

Configure the service to run automatically with services.msc or follow e.g. Chang Yin's answer to WMI corrupt - how to reinstall/repair?.

answered on Stack Overflow Apr 1, 2015 by JosefZ

User contributions licensed under CC BY-SA 3.0