Empty package to uninstall an application

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
benoitpatin
Messages: 37
Registration: February 21, 2018 - 5:05 PM

March 22, 2018 - 09:44

Good morning,

- Installed WAPT version: 1.5.1.18 Community
- Linux Debian 9 server OS
- Operating system of the administration/package creation machine: Windows 10

I would like to create a source-free package with just one command to uninstall a program on my computers.

I do not have the original source code for the application.
Using the command wapt-get list-registry software_name I am able to retrieve the Uninstallstring and the uninstallkey on a target machine.

So I foolishly created an empty package with the given information:

Code: Select all

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

uninstallkey = ['Foxit Reader_is1']


def uninstall():
    print('uninstalling Foxit Reader')
    run(r'"C:\Program Files (x86)\Foxit Software\Foxit Reader\unins000.exe"')
But it doesn't seem to be working properly. Since this is my second package, I think I'm missing a couple of things to get it right.
Is there anyone who can help me?

THANKS
User avatar
agauvrit
WAPT Expert
Messages: 238
Registration: Nov 17, 2016 - 10:25
Location: Nantes
Contact :

March 22, 2018 - 10:03

Hello Benoît,

The function uninstall This allows you to uninstall software deployed with WAPT. If you want to uninstall software directly, you must write this code in the function install from the package.

If you want to uninstall software in all possible versions, it's best to use a function like this:

Code: Select all

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

uninstallkey = []

def install():
    for soft in installed_softwares('Foxit Reader'):
        if Version(soft['version']) < Version('18'):
                run(WAPT.uninstall_cmd(soft['key']))
benoitpatin
Messages: 37
Registration: February 21, 2018 - 5:05 PM

March 22, 2018 - 2:17 PM

Great, the quick response! :D

However, I need some clarification...

Code: Select all

def install():
    for soft in installed_softwares('Foxit Reader'):
        if Version(soft['version']) < Version('18'):
                run(WAPT.uninstall_cmd(soft['key']))
The word "version" between a single quote and a bracket should correspond to the version in my Add/Remove Programs?
What should the word "key" between a single quote and a square bracket correspond to? The uninstallkey or the uninstallstring?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

March 22, 2018 - 2:46 PM

benoitpatin wrote: March 22, 2018 - 2:17 PM Does the word "version" between a single quote and a bracket refer to the version in my Add/Remove Programs?
Yes
benoitpatin wrote: March 22, 2018 - 2:17 PM What should the word "key" between a single quote and a square bracket refer to? The uninstallkey or the uninstallstring?
The word 'key' should not be replaced; we will retrieve the 'key' value from the `uninstallkey` currently being tested
benoitpatin
Messages: 37
Registration: February 21, 2018 - 5:05 PM

March 22, 2018 - 2:57 PM

Okay, great, here is min setup.py:

Code: Select all

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

uninstallkey = ['Foxit Reader_is1']


def install():
    print('uninstalling Foxit Reader')
    for soft in installed_softwares('Foxit Reader'):
        if Version(soft['version']) < Version('8.2.1.6871'):
            run(WAPT.uninstall_cmd(soft['key']))
I build, I upload, I launch the package on my machine but nothing happens.
I haven't made any mistakes anywhere. Did I miss something?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

March 22, 2018 - 3:17 PM

I don't see any errors in your code.

On the machine you are testing on.

Can you run a:

Code: Select all

wapt-get list-registry Foxit


to see what happens
User avatar
agauvrit
WAPT Expert
Messages: 238
Registration: Nov 17, 2016 - 10:25
Location: Nantes
Contact :

March 22, 2018 - 3:18 PM

To see the list of potentially affected software:

Code: Select all

wapt-get list-registry Foxit Reader
If the software does not appear, it will not be uninstalled; you may need to use only "Foxit" as a search keyword

Alexander
benoitpatin
Messages: 37
Registration: February 21, 2018 - 5:05 PM

March 22, 2018 - 3:22 PM

Code: Select all

UninstallKey                           Software                                                              Version             Uninstallstring                        
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foxit Reader_is1                       Foxit Reader                                                          8.2.1.6871          "C:\Program Files (x86)\Foxit Software\Foxit Reader\unins000.exe"
User avatar
agauvrit
WAPT Expert
Messages: 238
Registration: Nov 17, 2016 - 10:25
Location: Nantes
Contact :

March 22, 2018 - 3:27 PM

the returned version is equal to the version imposed in the version test (8.2.1.6871) so it is not uninstalled.

To be more "brute forceful," you can write the complete uninstallation of all possible versions like this:

Code: Select all

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

uninstallkey = ['Foxit Reader_is1']


def install():
    print('uninstalling Foxit Reader')
    for soft in installed_softwares('Foxit Reader'):
            run(WAPT.uninstall_cmd(soft['key']))
benoitpatin
Messages: 37
Registration: February 21, 2018 - 5:05 PM

March 22, 2018 - 5:32 PM

It's not working and I don't see any error message anywhere (at the same time, maybe there isn't one...an error!).
How can I troubleshoot?
Locked