"Auto-migration" (uninstallation/reinstallation) via the audit() function and system context

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
i551f
Messages: 1
Registration: Nov. 25, 2025 - 11:50

November 25, 2025 - 12:05

Hello everyone,

I am currently working on a script to standardize our software inventory. My goal is to periodically identify software that has been installed manually (outside of WAPT) and, if it corresponds to a package in our store, to force its uninstallation and reinstall it properly via WAPT.

I had considered using the audit() function for this task, with logic like this:

Code: Select all

def audit():
    # ... logique de détection ...
    if logiciel_hors_wapt_detecte:
        # Tentative de désinstallation
        run(WAPT.uninstall_cmd(app["msi_product_code"]))
        return "ERROR" # Pour déclencher une réinstallation ?
    return "OK"
However, I have doubts about the relevance and technical feasibility of this method, and I would like to confirm my intuition with you:

Execution context: audit() is executed by the WAPT service (Local System). If the uninstallation command invokes a graphical interface (even a simple confirmation), I imagine it will fail or hang because the service cannot interact with the user session (Session 0 problem)?

User interaction: Similarly, I imagine that using waptguihelper to notify the user is prohibited in the audit for the same reasons?

Is it recommended to make "heavy" changes (uninstallation) in the audit(), or should the audit simply report an "ERROR" status?

If audit() is not the right place, what is the best practice for this scenario? Is there another recommended mechanism (session_setup())?

Sincerely
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

November 25, 2025 - 12:27

Good morning
i551f wrote: Nov 25, 2025 - 12:05 PM Hello everyone,

I'm currently working on a script to standardize our software. My goal is to periodically identify software that has been installed manually (outside of WAPT) and, if it matches a package from our store, force its uninstallation and reinstall it properly via WAPT.
The easiest way is to uninstall it from the wapt package.

If you install teams
If the WAPT Teams package is not installed, then install it. (The WAPT Teams installation package will uninstall Teams or correct the Teams installation if necessary.)

Regarding the GUI issue, it's a broader problem; the uninstallation must be silent. While it's possible to redirect a system account display to a standard user session, this is clearly a major security risk. Therefore, a method for performing a silent uninstallation must be found.
User avatar
vcardon
WAPT Expert
Messages: 278
Registration: Oct 06, 2017 - 10:55 p.m.
Location: Nantes, France

November 25, 2025 - 7:48 PM

Also, i551f, your goal should also be to understand how and why users still install software themselves.

If they can currently install/run software not supported by WAPT, then the first solution is to remove admin rights and apply SRPs to their home directories.

Otherwise, you'll spend all your time whack-a-moleing, and WAPT will only serve to bandage a growing, infected wound.
Vincent CARDON
Tranquil IT
Answer