Page 1 sur 1
[RESOLVED] Uninstall legacy software from machine
Posté : 22 janv. 2018 - 18:29
par empbilly
Hello wapters,
I wonder if with wapt I can uninstall a software that was already on the computer before installing the client?
Re: Uninstall legacy software from machine
Posté : 22 janv. 2018 - 20:29
par sfonteneau
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']))
Re: Uninstall legacy software from machine
Posté : 22 janv. 2018 - 21:04
par empbilly
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?
Re: Uninstall legacy software from machine
Posté : 22 janv. 2018 - 21:18
par sfonteneau
As you said, you need to create a wapt package that will uninstall the software.
Re: Uninstall legacy software from machine
Posté : 22 janv. 2018 - 21:48
par empbilly
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']))
Re: Uninstall legacy software from machine
Posté : 22 janv. 2018 - 22:00
par sfonteneau
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'))
Re: Uninstall legacy software from machine
Posté : 23 janv. 2018 - 12:25
par empbilly
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?
Re: Uninstall legacy software from machine
Posté : 23 janv. 2018 - 12:41
par sfonteneau
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']))
Re: Uninstall legacy software from machine
Posté : 23 janv. 2018 - 13:35
par empbilly
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:
ie: