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


def install():
    bin_name = glob.glob("pwfree-*online.exe")[0]

    #Uninstalling older versions of the software that can remain
    for to_uninstall in installed_softwares(name="MiniTool Partition Wizard Free"):
        if Version(to_uninstall["version"]) < Version(control.get_software_version()):
            print(f"Removing: {to_uninstall['name']} ({to_uninstall['version']})")
            killalltasks(ensure_list(control.impacted_process))
            run(uninstall_cmd(to_uninstall["key"]))
            wait_uninstallkey_absent(to_uninstall["key"])

    install_exe_if_needed(
        bin_name, silentflags="/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-",
        key = "{05D996FA-ADCB-4D23-BA3C-A7C184A8FAC6}_is1",
        min_version=control.get_software_version()
    )