Page 1 of 1

PSIM Trial Package

Published: June 21, 2023 - 10:24
by gaelds
Good morning,
I'm trying to create a package for the PSIM 2021B demo. The uninstallation key is indeed in the registry, but it's located in HKEY_CURRENT_USER:

Code: Select all

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\6305213B-44F4-476B-85A0-EB506EDB8E01_is1
The installation works by leaving "Key" blank in install_exe_if_needed, but for uninstallation I cannot use uninstall_cmd()This indicates
"FATAL ERROR: 2: The key Software\Microsoft\Windows\CurrentVersion\Uninstall\['6305213B-44F4-476B-85A0-EB506EDB8E01_is1'] can not be opened"
Is there another way to use this key to uninstall? Or is it necessary to use the command `run(r'%s /verysilent' % uninstall_string)`?

Here is the code for my setup.py:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
setup_binary_name = glob.glob("PSIM*.exe")[0]
app_name  = "_".join(setup_binary_name.split("_")[:2])
app_dir = makepath('C:\Powersim')
app_dir_binaries = makepath(app_dir,"_".join(setup_binary_name.split("_")[:3]))
binary_name = "PSIM.exe"
kill_list = [binary_name]
shortcutsdir = makepath(common_desktop(),'Logiciels','Elec - Automatisme')
uninstallkey_psim = ['6305213B-44F4-476B-85A0-EB506EDB8E01_is1']
uninstall_string = r'%s\unins000.exe' %app_dir_binaries

def install():
    print(r'Suppression des anciens PSIM')
    run_notfatal(r'C:\Powersim\PSIM11.1.1_Demo\unins000.exe /verysilent')
    run_notfatal(r'MsiExec.exe /qn /X{D46F2B61-FEE0-46AF-B57F-0EF74F0ECC98}')
    if isfile(makepath(shortcutsdir,'PSIM.lnk')):
        remove_file(makepath(shortcutsdir,'PSIM.lnk'))
        
    print(r'Installation de %s' % app_name)
    killalltasks(kill_list)
    install_exe_if_needed(setup_binary_name,
        silentflags='/VERYSILENT /SUPPRESSMSGBOXES /NORESTART',
        key='',
        min_version='2021b'
    )

    print(r'Création du raccourci %s dans %s' %(app_name,shortcutsdir))
    if not isdir(shortcutsdir):
        mkdirs(shortcutsdir)
    create_shortcut(makepath(shortcutsdir,'%s.lnk' %app_name), target=makepath(app_dir_binaries,binary_name))
    remove_desktop_shortcut('PSIM License Monitor')
    remove_desktop_shortcut(app_name)

def uninstall():
    print(r"Desinstallation de %s" %app_name)
    killalltasks(kill_list)
    ##uninstall_cmd(uninstallkey_psim)
    run_notfatal(r'%s /verysilent' % uninstall_string)
    if  isfile(makepath(shortcutsdir,'%s.lnk' %app_name)):
        remove_file(makepath(shortcutsdir,'%s.lnk' %app_name))
    if isdir(app_dir):
        remove_tree(app_dir)

def audit():
    if isfile(makepath(app_dir_binaries,binary_name)):
        return("OK")
    else:
        return("Erreur : %s est introuvable !" %binary_name)
         

And secondly, without the "audit()" function, or with a simple return("OK"), I always get an error: "Audit aborted due to exception: list index out of range"

Re: PSIM Trial Package

Published: June 26, 2023 - 11:20
by dcardon
Hi Gaël,

the uninstall_key variable allows you to override the uninstallation key the software provides, but it doesn't write it to the registry.

So there aren't many other ways to do it than what you've described for the uninstallation process.

Since the key isn't registered in the correct location in the registry, I think it would be even better not to specify `uninstall_key` at all. Otherwise, the `def audit()` function will try to search for it in the registry (this is the default behavior if no audit function is defined in the package). This must be generating the error message you're getting, which isn't pretty and which we'll fix.

If the software is trying to create the key in HKCU, it's because it thinks it's installing in the user environment. We should check if there's a flag to force a system-wide installation. And if not, contact the developer to see if they can fix the way their software works. Otherwise, you can put this software in the "podoware" category (software developed with their feet :-) ).

Sincerely,

Denis

Re: PSIM Trial Package

Published: June 26, 2023 - 7:24 PM
by gaelds
Thanks to Jimmy and Morgan who debugged this package for me this afternoon. This podoware installs and no longer returns errors on the console, that's enough for me ;)

Code: Select all

setup_binary_name = glob.glob("PSIM*.exe")[0]
has been replaced by

Code: Select all

setup_binary_name = 'PSIM_2021b_Demo_64bit_Setup.exe'
The version and timeout have been modified in the install_exe_if_needed command:

Code: Select all

install_exe_if_needed(setup_binary_name,
        silentflags='/VERYSILENT /SUPPRESSMSGBOXES /NORESTART',
        key='',
        min_version='',
        timeout=900
    )

Code: Select all

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

setup_binary_name = 'PSIM_2021b_Demo_64bit_Setup.exe'
app_name  = "_".join(setup_binary_name.split("_")[:2])
app_dir = makepath('C:\Powersim')
app_dir_binaries = makepath(app_dir,"_".join(setup_binary_name.split("_")[:3]))
binary_name = "PSIM.exe"
kill_list = [binary_name]
uninstallkey_psim = ['F8C0340D-A8CE-4B15-96C0-D3F6A564A9DF_is1']
uninstall_string = r'%s\unins000.exe' %app_dir_binaries

def install():
    if isfile(makepath(shortcutsdir,'PSIM.lnk')):
        remove_file(makepath(shortcutsdir,'PSIM.lnk'))
    print(r'Installation de %s' % app_name)
    killalltasks(kill_list)

    install_exe_if_needed(setup_binary_name,
        silentflags='/VERYSILENT /SUPPRESSMSGBOXES /NORESTART',
        key='',
        min_version='',
        timeout=900
    )

def uninstall():
    print(r"Desinstallation de %s" %app_name)
    killalltasks(kill_list)
    run_notfatal(r'%s /verysilent' % uninstall_string)
    if isdir(app_dir):
        remove_tree(app_dir)

Re: PSIM Trial Package

Published: June 26, 2023 - 10:44 PM
by vcardon
I like your use of the word "podoware," we invented it :)