Page 1 of 1

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

Published: April 1, 2026 - 5:13 PM
by erems
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.

Re: WAPT not executing the uninstall() function?

Published: April 8, 2026 - 4:47 PM
by erems
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.

Re: WAPT not executing the uninstall() function?

Published: April 8, 2026 - 5:16 PM
by sfonteneau
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

Re: WAPT not executing the uninstall() function?

Published: April 10, 2026 - 09:43
by erems
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.

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

Published: April 10, 2026 - 10:04 AM
by dcardon
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