problem with the wmi_info() function

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Answer
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

April 17, 2026 - 3:25 PM

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.
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

April 17, 2026 - 4:17 PM

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
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

April 17, 2026 - 4:50 PM

Hello Denis,

Understood, thank you! :)

Best regards
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

April 22, 2026 - 10:21

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,
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
Answer