Page 1 of 1
[RESOLVED] Uninstall legacy software from machine
Published: January 22, 2018 - 6:29 PM
by 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
Published: January 22, 2018 - 8:29 PM
by sfonteneau
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']))
Re: Uninstall legacy software from machine
Published: January 22, 2018 - 9:04 PM
by 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
Published: January 22, 2018 - 9:18 PM
by sfonteneau
As you said, you need to create a wapt package that will uninstall the software.
Re: Uninstall legacy software from machine
Published: January 22, 2018 - 9:48 PM
by empbilly
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']))
Re: Uninstall legacy software from machine
Published: January 22, 2018 - 10:00 PM
by sfonteneau
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'))
Re: Uninstall legacy software from machine
Published: January 23, 2018 - 12:25 PM
by empbilly
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?
Re: Uninstall legacy software from machine
Published: January 23, 2018 - 12:41
by sfonteneau
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']))
Re: Uninstall legacy software from machine
Published: January 23, 2018 - 1:35 PM
by empbilly
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