[RESOLVED] Uninstall legacy software from machine

Share here your tips or issues concerning WAPT Console or WAPT Agent / Venez ici partager vos problèmes et astuces concernants la console et l'agent WAPT
Règles du forum
Règles du forum communautaire
* English support on www.reddit.com/r/wapt
* Le support communautaire en français se fait sur ce forum
* Merci de préfixer le titre du topic par [RESOLU] s'il est résolu.
* Merci de ne pas modifier un topic qui est taggé [RESOLU]. Ouvrez un nouveau topic en référençant l'ancien
* Préciser version de WAPT installée, version complète ET numéro de build (2.2.1.11957 / 2.2.2.12337 / etc.) AINSI QUE l'édition Enterprise / Discovery
* Les versions 1.8.2 et antérieures ne sont plus maintenues. Les seules questions acceptées vis à vis de la version 1.8.2 sont liés à la mise à jour vers une version supportée (2.1, 2.2, etc.)
* Préciser OS du serveur (Linux / Windows) et version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019)
* Préciser OS de la machine d'administration/création des paquets et de la machine avec l'agent qui pose problème le cas échéant (Windows 7 / 10 / 11 / Debian 11 / etc.)
* Eviter de poser plusieurs questions lors de l'ouverture de topic, sinon il risque d'être ignorer. Si plusieurs sujet, ouvrir plusieurs topic, et de préférence les uns après les autres et pas tous en même temps (ie ne pas spammer le forum).
* Inclure directement les morceaux de code, les captures d'écran et autres images directement dans le post. Les liens vers les pastebin, les bitly et autres sites tierces seront systématiquement supprimés.
* Comme tout forum communautaire, le support est fait bénévolement par les membres. Si vous avez besoin d'un support commercial, vous pouvez contacter le service commercial Tranquil IT au 02.40.97.57.55
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

22 janv. 2018 - 18:29

Hello wapters,

I wonder if with wapt I can uninstall a software that was already on the computer before installing the client?
Dernière modification par empbilly le 15 mars 2018 - 13:42, modifié 2 fois.
Avatar de l’utilisateur
sfonteneau
Expert WAPT
Messages : 1783
Inscription : 10 juil. 2014 - 23:52
Contact :

22 janv. 2018 - 20:29

yes here is a sample code :

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

Code : Tout sélectionner

for soft in installed_softwares('winscp3'):
                run(WAPT.uninstall_cmd(soft['key']))
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

22 janv. 2018 - 21:04

sfonteneau a écrit : 22 janv. 2018 - 20:29 yes here is a sample code :

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

Code : Tout sélectionner

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?
Avatar de l’utilisateur
sfonteneau
Expert WAPT
Messages : 1783
Inscription : 10 juil. 2014 - 23:52
Contact :

22 janv. 2018 - 21:18

As you said, you need to create a wapt package that will uninstall the software.
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

22 janv. 2018 - 21:48

sfonteneau a écrit : 22 janv. 2018 - 21:18 As you said, you need to create a wapt package that will uninstall the software.
Ok. Like this?

setup.py

Code : Tout sélectionner

# -*- 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']))
Avatar de l’utilisateur
sfonteneau
Expert WAPT
Messages : 1783
Inscription : 10 juil. 2014 - 23:52
Contact :

22 janv. 2018 - 22:00

Your code works. I propose to simplify it:

Code : Tout sélectionner

def install():
    if uninstall_key_exists('1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'):
        run(WAPT.uninstall_cmd('1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'))
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

23 janv. 2018 - 12:25

sfonteneau a écrit : 22 janv. 2018 - 22:00 Your code works. I propose to simplify it:

Code : Tout sélectionner

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 columm "Uninstall key" from Software Inventory in wapt console, right?
Avatar de l’utilisateur
sfonteneau
Expert WAPT
Messages : 1783
Inscription : 10 juil. 2014 - 23:52
Contact :

23 janv. 2018 - 12:41

empbilly a écrit : 23 janv. 2018 - 12:25 This "key" is the value found in the columm "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 uninstallkey "'1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'"



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

Code : Tout sélectionner

for soft in installed_softwares('winscp3'):
                run(WAPT.uninstall_cmd(soft['key']))
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

23 janv. 2018 - 13:35

sfonteneau a écrit : 23 janv. 2018 - 12:41
empbilly a écrit : 23 janv. 2018 - 12:25 This "key" is the value found in the columm "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 uninstallkey "'1233A4A7-BA0B-4067-BE21-FB97AFABC0CF'"



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

Code : Tout sélectionner

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 : Tout sélectionner

# -*- 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 : Tout sélectionner

wapt-get build-package <path of the files>
ie:

Code : Tout sélectionner

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