[SOLVED] WAPT's uninstall() function not executed?

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
Locked
erems
Messages: 46
Registration: Apr 25, 2023 - 3:52 p.m.

April 1, 2026 - 5:13 PM

Good morning,

We are currently working on a DinoCapture package; here is the setup.py file:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls

uninstallkey = r'{683A259B-BCA2-4161-9B23-2110F2AE472C}'
iss_path = r"C:\Program Files\DinoCapture-2.0-Uninstall"

def install():
    copytree2('DNC2_AP',iss_path)
    # Installing the software
    print("Installing: DinoCapture 2.0")
    install_exe_if_needed(rf'{iss_path}\setup.exe',
        silentflags='/s',
        key=uninstallkey,
        min_version='1.5.57.A'
    )

def uninstall():
    # Declaring local variables
    setupfile = rf'{iss_path}\setup.exe'
    uninst_file = rf'{iss_path}\uninstall.iss'
    if isfile(uninst_file):
        print("Lancement de la désinstallation DinoCapture")
        uninstallcmd = rf'"{setupfile}" /s /f1"{uninst_file}"'
        print(uninstallcmd)
        run(
            uninstallcmd,
            accept_returncodes=[0,1605,1614,1641,3010,2147753984]
        )
        remove_tree(iss_path)
    else:
        print("Fichier non trouvé : ", uninst_file)
From within PyScripter, the installation and uninstallation functions work correctly. The uninstallation produces the expected output:

Code: Select all

Ligne de Commande : uninstall "C:\Users\user-adm\Desktop\erems-dinocapture_1.5.57_Windows_PROD-wapt\WAPT\.."
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Uninstalling C:\Users\user-adm\Desktop\erems-dinocapture_1.5.57_Windows_PROD-wapt ...
Lancement de la désinstallation DinoCapture
"C:\Program Files\DinoCapture-2.0-Uninstall\setup.exe" /s /f1"C:\Program Files\DinoCapture-2.0-Uninstall\uninstall.iss"
2026-04-01 16:13:41,591 WARNING "C:\Program Files\DinoCapture-2.0-Uninstall\setup.exe" /s /f1"C:\Program Files\DinoCapture-2.0-Uninstall\uninstall.iss" command returns code 2147753984
None
Uninstallation done
The package imported into WAPT installs correctly but does not uninstall properly:

Code: Select all

Waiting for the removal of key: {683A259B-BCA2-4161-9B23-2110F2AE472C} from Windows registry
Fatal error : Uninstallkey still present
Traceback (most recent call last):
  File "<string>", line 1693, in run
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 891, in run
    self._run()
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 1544, in _run
    self.result = self.wapt.remove(self.packagenames,
  File "C:\Program Files (x86)\wapt\common.py", line 6017, in remove
    setuphelpers.error('Uninstallkey still present')
  File "C:\Program Files (x86)\wapt\waptutils.py", line 2176, in error
    raise EWaptSetupException('Fatal error : %s' % reason)
waptutils.EWaptSetupException: Fatal error : Uninstallkey still present

EWaptSetupException: Fatal error : Uninstallkey still present
Traceback (most recent call last):
  File "<string>", line 1693, in run
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 891, in run
    self._run()
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 1544, in _run
    self.result = self.wapt.remove(self.packagenames,
  File "C:\Program Files (x86)\wapt\common.py", line 6017, in remove
    setuphelpers.error('Uninstallkey still present')
  File "C:\Program Files (x86)\wapt\waptutils.py", line 2176, in error
    raise EWaptSetupException('Fatal error : %s' % reason)
waptutils.EWaptSetupException: Fatal error : Uninstallkey still present
I don't have the logs; it seems my custom uninstall function isn't being executed (?)
Do you know why?

Thank you for your help.
Best regards.
Last edited by erems on Apr 10, 2026 - 09:43, edited 1 time.
erems
Messages: 46
Registration: Apr 25, 2023 - 3:52 p.m.

April 8, 2026 - 4:47 PM

Good morning,

I revisited the issue today and I think it's a bug (WAPT 2.6.1.17765) because on a machine with the package installed:
- if I uninstall the package from the console I get the error indicated in my initial post (and the software is still on the machine).
- if I go to the computer and run: wapt-get uninstall erems-dinocapture -l debug

Code: Select all

[DEBUG] Logging TSynLog with level=debug to C:\Program Files (x86)\wapt\log\wapt-get.log
2026-04-08 16:42:30,680 DEBUG Default encoding : utf-8
2026-04-08 16:42:30,680 DEBUG Caller: ['', 'uninstall', 'erems-dinocapture', '-l', 'debug']
2026-04-08 16:42:30,680 DEBUG Python path ['C:\\Program Files (x86)\\wapt', 'C:\\Program Files (x86)\\wapt\\python310.zip', 'C:\\Program Files (x86)\\wapt', 'C:\\Program Files (x86)\\wapt\\DLLs', 'C:\\Program Files (x86)\\wapt\\lib\\site-packages', 'C:\\Program Files (x86)\\wapt\\lib\\site-packages\\win32', 'C:\\Program Files (x86)\\wapt\\lib\\site-packages\\win32\\lib', 'C:\\Program Files (x86)\\wapt\\lib\\site-packages\\Pythonwin']
2026-04-08 16:42:30,680 INFO Using local waptservice configuration C:\Program Files (x86)\wapt\wapt-get.ini
2026-04-08 16:42:30,680 DEBUG Config file: C:\Program Files (x86)\wapt\wapt-get.ini
2026-04-08 16:42:30,680 INFO Using openssl OpenSSL 3.5.5 27 Jan 2026
2026-04-08 16:42:30,680 DEBUG Thread 11812 is connecting to wapt db
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
2026-04-08 16:42:30,699 INFO User Groups:[]
2026-04-08 16:42:30,699 DEBUG Using host certificate C:\Program Files (x86)\wapt\private\4c4c4544-0053-5410-8034-c4c04f374a32.pem for repo global auth
2026-04-08 16:42:30,699 DEBUG 11812 Loading config from file C:\Program Files (x86)\wapt\conf.d\cfg-all-maturities.json
2026-04-08 16:42:30,699 DEBUG 11812 Loading config from file C:\Program Files (x86)\wapt\conf.d\cfg-windows-update.json
2026-04-08 16:42:30,699 DEBUG 11812 Loading config from file C:\Program Files (x86)\wapt\conf.d\Config_Maturities.json
2026-04-08 16:42:30,699 INFO WAPT base directory : C:\Program Files (x86)\wapt
2026-04-08 16:42:30,699 DEBUG Checking if old install in progress
2026-04-08 16:42:30,716 DEBUG reset stalled install_status in database
2026-04-08 16:42:30,716 DEBUG Thread 11812 is connecting to wapt db
Uninstalling erems-dinocapture ...
2026-04-08 16:42:30,728 DEBUG Sourcing setup from DB
2026-04-08 16:42:30,728 INFO   sourcing setuppy file None
2026-04-08 16:42:30,728 DEBUG Import source code as __waptsetup_CMXIWURP55__
2026-04-08 16:42:30,744 INFO   executing setup.uninstall({})
Lancement de la désinstallation DinoCapture
"C:\Program Files\DinoCapture-2.0-Uninstall\setup.exe" /s /f1"C:\Program Files\DinoCapture-2.0-Uninstall\uninstall.iss"
2026-04-08 16:42:30,744 INFO Run ""C:\Program Files\DinoCapture-2.0-Uninstall\setup.exe" /s /f1"C:\Program Files\DinoCapture-2.0-Uninstall\uninstall.iss""
2026-04-08 16:42:46,256 WARNING "C:\Program Files\DinoCapture-2.0-Uninstall\setup.exe" /s /f1"C:\Program Files\DinoCapture-2.0-Uninstall\uninstall.iss" command returns code 2147753984
2026-04-08 16:42:46,316 DEBUG Removing module: __waptsetup_CMXIWURP55__, refcnt: 3
2026-04-08 16:42:46,316 DEBUG   Change current directory to C:\Windows\System32
None
Uninstallation done
20260408 14424619  ! rotat wapt-get 2.6.1.17765 TSynLog 2.4.13434 {4 9.47 7.05 3.6GB/7.9GB 66581b01}
20260408 14424619  ! info  SetThreadName 1 2e24 11812=Main
20260408 14424619  ! info  wapt-get terminate
Everything is going well, we can see that the uninstall function is correctly called and the software is indeed uninstalled.

Could you please help us? I can send you the package source code if you wish.
THANKS.
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

April 8, 2026 - 5:16 PM

Good morning

Sorry, I thought I had replied to your post, but apparently not

Add this line to the end of the install command in your code:

Code: Select all

uninstallkey.remove(r'{683A259B-BCA2-4161-9B23-2110F2AE472C}')
to ask Wapt to forget the key and not to save this key in the Wapt database
erems
Messages: 46
Registration: Apr 25, 2023 - 3:52 p.m.

April 10, 2026 - 09:43

Hello,

thank you very much, it does indeed work.

Is this something that needs to be done systematically when using a custom uninstall() function in a WAPT package?

Regards.
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

April 10, 2026 - 10:04

Hello erems,

the uninstall function complements the uninstallation function integrated by default in Wapt with the uninstallkey.

Therefore, if you explicitly uninstall within your uninstall command, you must remove the uninstallkey; otherwise, the uninstall command will be executed twice (and will therefore crash). We'll take a look at the documentation to see if this can be explained better.

In any case, thank you for the feedback :-)

. Best 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
Locked