Page 1 of 1

problem with the wmi_info() function

Published: April 17, 2026 - 3:25 PM
by brice73
Good morning,

I installed the tis-audi-wmi package, and it works well and correctly reports wmi information in the audit data.

In wapt packages, I used to use the wmi_info() function, but now when I test it in pyscripter, it consistently fails with the same errors:

Code: Select all

*** Python 3.10.19 (main, Jan 29 2026, 18:58:30) [MSC v.1929 32 bit (Intel)] on win32. ***
*** Distant Python engine is active ***
>>> from setuphelpers import *
>>> wmi_info_test1=wmi_info(keys=['Win32_ComputerSystem','Win32_ComputerSystemProduct','Win32_BIOS'])
WMI error Invalid value for list argument, fallback to py wmi
>>> wmi_info_test1=wmi_info(keys=['Win32_ComputerSystem','Win32_ComputerSystemProduct','Win32_BIOS'])
WMI error Invalid value for list argument, fallback to py wmi
WMI is broken on this computer. See https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-rebuilding-the-wmi-repository/ba-p/373846 : x_wmi_uninitialised_thread: <x_wmi: WMI returned a syntax error: you're probably running inside a thread without first calling pythoncom.CoInitialize[Ex] (no underlying exception)>
>>> wmi_info_test2=wmi_info(keys=['Win32_NetworkAdapter','Win32_PhysicalMemory','Win32_Printer','Win32_VideoController'])
WMI error Invalid value for list argument, fallback to py wmi
WMI is broken on this computer. See https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-rebuilding-the-wmi-repository/ba-p/373846 : x_wmi_uninitialised_thread: <x_wmi: WMI returned a syntax error: you're probably running inside a thread without first calling pythoncom.CoInitialize[Ex] (no underlying exception)>
>>> 
This occurs on different machines, therefore regardless of the Windows version

However, I am using the correct syntax and expected values ​​for the keys parameter, similar to those of the package's audit function:

Code: Select all

def audit():

    wmi_keys = ['Win32_ComputerSystem','Win32_ComputerSystemProduct','Win32_BIOS',
    'Win32_NetworkAdapter','Win32_PhysicalMemory','Win32_Printer','Win32_VideoController',
    'Win32_LogicalDisk','Win32_OperatingSystem','Win32_DesktopMonitor',
    'Win32_USBController','Win32_SystemEnclosure','Win32_DiskDrive',
    'Win32_Volume','Win32_PnPSignedDriver']

    data_wmi_info = wmi_info(keys = wmi_keys)
    WAPT.write_audit_data_if_changed("audit-wmi", "audit-wmi", data_wmi_info)
    return "OK
I verified that wmi was correct (winmgmt /verifyrepository OK) and the audi-wmi package correctly retrieves wmi information.

Do you see what the problem is? I would like to be able to use the very practical wmi_info() function in packages, which collects a lot of data.

Re: Problem with the wmi_info() function

Published: April 17, 2026 - 4:17 PM
by dcardon
Hi Brice,

if I remember correctly, there have been changes to the way WMI information is retrieved to better handle gen_py issues (the creation of Python stub files to call COM objects, especially WMI) and other CoInitialize problems (a Microsoft feature for COM objects as well). I'll check internally to see what's going on.

Regards,

Denis

Re: Problem with the wmi_info() function

Published: April 17, 2026 - 4:50 PM
by brice73
Hello Denis,

Understood, thank you! :)

Best regards

Re: Problem with the wmi_info() function

Published: April 22, 2026 - 10:21
by brice73
Hi Denis,

just a quick update to confirm that the wmi_info() function, when used within a package's install function, appears to work (returning the WMI information dictionary).

So, the wmi_info() function works within the context of installing or auditing a package, but not outside of it (for example, in PyScripter outside of a package installation).

Regards,