[RESOLVED] Uninstall legacy software from machine

Share your tips or issues concerning the WAPT Console or WAPT Agent here
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
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

January 22, 2018 - 6:29 PM

Hello wapters,

I wonder if with wapt I can uninstall a software that was already on the computer before installing the client?
Last edited by empbilly on March 15, 2018 - 13:42, edited 2 times.
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

January 22, 2018 - 8:29 PM

Yes, here is a sample code:

https://www.wapt.fr/en/doc/CreationPaqu ... -logiciels

Code: Select all

for soft in installed_softwares('winscp3'):
                run(WAPT.uninstall_cmd(soft['key']))
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

January 22, 2018 - 9:04 PM

sfonteneau wrote: January 22, 2018 - 8:29 PM Yes, here is a sample code:

https://www.wapt.fr/en/doc/CreationPaqu ... -logiciels

Code: Select all

for soft in installed_softwares('winscp3'):
                run(WAPT.uninstall_cmd(soft['key']))
Sorry for the question, but I run this code in some place or save this as a wapt package and link to the computer or none of this?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

January 22, 2018 - 9:18 PM

As you said, you need to create a wapt package that will uninstall the software.
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

January 22, 2018 - 9:48 PM

sfonteneau wrote: Jan 22, 2018 - 9:18 p.m. As you said, you need to create a wapt package that will uninstall the software.
Okay. Like this?

setup.py

Code: Select all

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

uninstallkey=[]

def install():

    softname = 'firefox'
    check_installed_soft = installed_softwares(softname)
    if check_installed_soft:
             for uninstall in check_installed_soft:
                key=uninstall['1233A4A7-BA0B-4067-BE21-FB97AFABC0CF']
                if installed_softwares(uninstallkey=key):
                         run(WAPT.uninstall_cmd(uninstall['key']))
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

January 22, 2018 - 10:00 PM

Your code works. I propose to simplify it:

Code: Select all

def install():
    if uninstall_key_exists('1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'):
        run(WAPT.uninstall_cmd('1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'))
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

January 23, 2018 - 12:25

sfonteneau wrote: January 22, 2018 - 10:00 PM Your code works. I propose to simplify it:

Code: Select all

def install():
    if uninstall_key_exists('1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'):
        run(WAPT.uninstall_cmd('1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'))
sfonteneau,

This "key" is the value found in the column "Uninstall key" from Software Inventory in wapt console, right?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

January 23, 2018 - 12:41

empbilly wrote: Jan 23, 2018 - 12:25 This "key" is the value found in the column "Uninstall key" from Software Inventory in wapt console, right?
Yes!
you can also find the uninstallkey with this command: https://www.wapt.fr/en/doc/Utilisation/ ... t-registry

The second code I provided you can uninstall software that has the uninstall key "'1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'"



This code bellow allows you to uninstall all the software that uses the word "winscp" in the information of their uninstall key.

Code: Select all

for soft in installed_softwares('winscp3'):
                run(WAPT.uninstall_cmd(soft['key']))
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

January 23, 2018 - 1:35 PM

sfonteneau wrote: January 23, 2018 - 12:41
empbilly wrote: Jan 23, 2018 - 12:25 This "key" is the value found in the column "Uninstall key" from Software Inventory in wapt console, right?
Yes!
you can also find the uninstallkey with this command: https://www.wapt.fr/en/doc/Utilisation/ ... t-registry

The second code I provided you can uninstall software that has the uninstall key "'1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'"



This code bellow allows you to uninstall all the software that uses the word "winscp" in the information of their uninstall key.

Code: Select all

for soft in installed_softwares('winscp3'):
                run(WAPT.uninstall_cmd(soft['key']))
Now works!!! Thanks for the help sfonteneau!!! :)

The code for uninstalling only with the key, not worked, but with the code above, works like a charm!

In the end, the code is like:

Code: Select all

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

uninstallkey=[]

def install():
	for soft in installed_softwares('old_version_of_firefox'):
                run(WAPT.uninstall_cmd(soft['key']))
For new users, remember to create or copy the "control" and "wapt.psproj" files and place them inside the "WAPT" folder in the package root, ie along with the "setup.py" file.

After that, you need to build the package with the below command:

Code: Select all

wapt-get build-package <path of the files>
i.e.:

Code: Select all

wapt-get build-package c:\waptdev\test-remove-firefox
Locked