Page 1 of 1
[SOLVED] PyScripter shortcut
Published: February 27, 2024 - 12:00 PM
by rcharpeil
WAPT server: 2.4 Debian 11 Bullseye
Console Admin: Windows 10, WAPT 2.4
FlameShot package
Hello, as I don't have much knowledge of PyScripter, I would like to add a line to the FlameShot package configuration that would automatically add the software shortcut to \AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup to launch FlameShot automatically at startup.
Can you help me?
Thank you in advance
.
Re: PyScripter shortcut
Published: February 28, 2024 - 4:12 PM
by dcardon
Hello Romain,
It's better to put it in the machine's startup menu rather than the user's, unless you want to allow users to delete it.
Code: Select all
create_programs_menu_shortcut('test',target=makepath(programfiles, "Flameshot","bin", "flameshot.exe"),folder='StartUp'
Sincerely,
Denis
Re: PyScripter shortcut
Published: February 29, 2024 - 10:11 AM
by rcharpeil
Hello, with the help of my superiors and you, I've created a working script that installs the application and adds a shortcut to the Windows taskbar and the Startup folder for all users of the computer. I'm sharing the code here for anyone who might be interested.
Regards
Code: Select all
from setuphelpers import *
import subprocess
r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
"""
# Déclaration des variables globales - Avertissements : 1) Le contexte WAPT n'est disponible que dans les fonctions de paquet ; 2) Les variables globales ne sont pas persistantes entre les appels
def install():
# Déclaration des variables locales
# Installation du logiciel
print("Installation : Flameshot-12.1.0-win64.msi")
install_msi_if_needed('Flameshot-12.1.0-win64.msi')
# Chemin vers le dossier de démarrage commun pour tous les utilisateurs
all_users_startup_folder = os.path.join(os.getenv('ProgramData'), 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup')
# Création du raccourci dans le dossier de démarrage commun pour tous les utilisateurs
create_programs_menu_shortcut("Flameshot", makepath(programfiles, "Flameshot", "bin", "flameshot.exe"), folder=all_users_startup_folder)
# Lancement de Flameshot
print("Lancement de Flameshot...")
subprocess.Popen(makepath(programfiles, "Flameshot", "bin", "flameshot.exe"))
def uninstall():
# Suppression du raccourci du dossier de démarrage commun pour tous les utilisateurs
remove()
def remove():
# Chemin vers le raccourci dans le dossier de démarrage commun pour tous les utilisateurs
all_users_startup_folder = os.path.join(os.getenv('ProgramData'), 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup')
shortcut_path = os.path.join(all_users_startup_folder, "Flameshot.lnk")
# Vérifier si le fichier du raccourci existe, puis le supprimer
if os.path.exists(shortcut_path):
os.remove(shortcut_path)
print("Raccourci supprimé avec succès.")
else:
print("Le raccourci n'existe pas.")
Re: PyScripter shortcut
Published: February 29, 2024 - 11:58 AM
by dcardon
Hi Romain,
thanks for the feedback,

I'm marking the topic as RESOLVED.
Denis