"Auto-migration" (uninstallation/reinstallation) via the audit() function and system context
Published: November 25, 2025 - 12:05 PM
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:
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
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"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