WAPT antivirus removal package

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
Locked
Eyji
Messages: 13
Registration: February 15, 2022 - 09:32

February 15, 2022 - 11:01

Good morning,

I'm trying to create a package to uninstall the old antivirus via a registry key, but there are several different versions, therefore several registry keys.
I want it to check the registry keys and if it exists it uninstalls it and if it does not exist it moves on to the next one and at the end install the new anti-virus and if it is x64 install the 64-bit version or if it is an x86 operating system install the 32-bit version.
Attached is the script I started writing but it's not working.
Thank you in advance to anyone who can help me.

Code: Select all

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

# Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls


def install():
    print("Installing: %s" % control.package)

if uninstall_key_exists('{867E468E-DD24-4599-8A61-C4454DD166FE}'):
        run('MSIEXEC.exe /qb /X {867E468E-DD24-4599-8A61-C4454DD166FE} REBOOT="ReallySuppress" PASSWORD="mot de passe" /q')

elif uninstall_key_exists('{367F9C22-8DC9-4880-A14B-29B01881B05C}'):
        run('MSIEXEC.exe /qb /X {367F9C22-8DC9-4880-A14B-29B01881B05C} REBOOT="ReallySuppress" /q')

else: uninstall_key_exists('{B454B5C8-5C87-4F24-B9F5-2A9A199F08F5}')
        run('MSIEXEC.exe /qb /X {B454B5C8-5C87-4F24-B9F5-2A9A199F08F5} REBOOT="ReallySuppress" /q')

else: uninstall_key_exists('{7F98FC14-7576-4980-8985-BD5377EA765E}')
        run('MSIEXEC.exe /qb /X {7F98FC14-7576-4980-8985-BD5377EA765E} REBOOT="ReallySuppress" PASSWORD="mot de passe" /q')

else: uninstall_key_exists('{7B3EFEF0-4D31-4221-8BA3-B1B1CBBAA5B8}')
        run('MSIEXEC.exe /qb /X {7B3EFEF0-4D31-4221-8BA3-B1B1CBBAA5B8} REBOOT="ReallySuppress" /q')

else: uninstall_key_exists('{92BA3DCC-50FA-4636-939F-254D454D2559}')
        run('MSIEXEC.exe /qb /X {92BA3DCC-50FA-4636-939F-254D454D2559} REBOOT="ReallySuppress" /q')

else: uninstall_key_exists('{26172EAA-2147-47B0-ABFB-D5FF4E6D4274}')
        run('MSIEXEC.exe /qb /X {26172EAA-2147-47B0-ABFB-D5FF4E6D4274} REBOOT="ReallySuppress" PASSWORD="mot de passe" /q')

else: uninstall_key_exists('{7B3EFEF0-4D31-4221-8BA3-B1B1CBBAA5B8}')
        run('MSIEXEC.exe /qb /X {7B3EFEF0-4D31-4221-8BA3-B1B1CBBAA5B8} REBOOT="ReallySuppress" /q')

else: uninstall_key_exists('{8DDDE767-7175-46A3-BF28-939E8B755617}')
        run('MSIEXEC.exe /qb /X {8DDDE767-7175-46A3-BF28-939E8B755617} REBOOT="ReallySuppress" PASSWORD="mot de passe" /q')

else: uninstall_key_exists('{92BA3DCC-50FA-4636-939F-254D454D2559}')
        run('MSIEXEC.exe /qb /X {92BA3DCC-50FA-4636-939F-254D454D2559} REBOOT="ReallySuppress" /q')

else: uninstall_key_exists('{3F509AE4-E4F1-4418-B0C2-92766748DC02}')
        run('MSIEXEC.exe /qb /X {3F509AE4-E4F1-4418-B0C2-92766748DC02} REBOOT="ReallySuppress" PASSWORD="mot de passe" /q')

else: uninstall_key_exists('{F9699917-447C-4109-9479-5161D1636B24}')
        run('MSIEXEC.exe /qb /X {F9699917-447C-4109-9479-5161D1636B24} REBOOT="ReallySuppress" /q')

else: uninstall_key_exists('{082F6817-E4B9-406D-8E59-0551070D7B97}')
        run('MSIEXEC.exe /qb /X {082F6817-E4B9-406D-8E59-0551070D7B97} REBOOT="ReallySuppress" PASSWORD="mot de passe" /q')

else: uninstall_key_exists('{E75932C3-67DD-42A7-A413-E748199C17C2}')
        run('MSIEXEC.exe /qb /X {E75932C3-67DD-42A7-A413-E748199C17C2} REBOOT="ReallySuppress" PASSWORD="mot de passe" /q')

else: uninstall_key_exists('{19E36B07-F888-4822-BF50-49F9EA520018}')
        run('MSIEXEC.exe /qb /X {19E36B07-F888-4822-BF50-49F9EA520018} REBOOT="ReallySuppress" PASSWORD="mot de passe" /q')

else: uninstall_key_exists('{CAC9C8AF-7485-48E0-AF87-FDC929B57E76}')
        run('MSIEXEC.exe /qb /X {CAC9C8AF-7485-48E0-AF87-FDC929B57E76} REBOOT="ReallySuppress" PASSWORD="mot de passe" /q')

def install():
    print("Installing: %s" % control.package)

if iswin64():
    print('Pc x64')
    run(r'"agent_cloud_x64.msi" -q /norestart')
else:
    print('Pc not x64')
    run(r'"agent_cloud_x86.msi" -q /norestart')
olaplanche
Messages: 178
Registration: January 26, 2017 - 11:11

February 15, 2022 - 2:22 PM

Good morning,

Note that in your script you have defined the function def install() twice:
You also use the /q parameter twice for uninstallation, that strikes me as odd!

Personally, I would try with the code below:
It will check all installed versions of a given software (name=blabla), compare them to see if the version is lower than the version of the package to be installed, and automatically launch the uninstallation from the uninstallkey. If the uninstallkey is not silent, the run() command must be adapted

Code: Select all

   # Uninstalling older versions of the software
    for to_uninstall in installed_softwares(name=r"lenomdemonantivirus"):
        if Version(to_uninstall["version"]) < Version(package_version) or force:
            print("Removing: %s (%s)" % (to_uninstall["name"], to_uninstall["version"]))
            killalltasks(control.impacted_process.split(","))
            run(uninstall_cmd(to_uninstall["key"]))
            wait_uninstallkey_absent(to_uninstall["key"])
- Installed WAPT version: 2.6.0.16795 Enterprise
- Server OS: Linux / Debian Bookworm
- Administration/package creation machine OS: Windows 10
Eyji
Messages: 13
Registration: February 15, 2022 - 09:32

February 15, 2022 - 3:09 PM

Hello,

thank you for your quick reply. :D
I apologize for forgetting to provide some information.
I'm uninstalling the old ESET antivirus to install TREND Micro antivirus, and to uninstall all previous versions of ESET, I absolutely must use the registry key with the admin password for uninstalling the antivirus because ESET uninstalls in safe mode via the uninstaller.
Each agent and each ESET version has its own registry key depending on the version installed.
Again, sorry.
Locked