Bonjour,
Merci de la réponse.
Après m'être renseigné sur le code de setuphelpers, j'ai remarqué qu'enfaite c'était tout simple (enfin je le suppose).
Si on regarde le code de création de shortcut (
https://www.wapt.fr/apidoc/wapt-2.6/win ... e_shortcut)
On trouve deux endroit (dans les 3 dernières lignes j'ai commenté) par rapport à cette index il manquerait plus qu'à ajouter l'argument je suppose.
Code : Tout sélectionner
def create_shortcut(path, target='', arguments='', wDir='', icon=''):
r"""Create a windows shortcut
Args:
path (str) : As what file should the shortcut be created?
target (str): What command should the desktop use?
arguments (str): What arguments should be supplied to the command?
wdir (str) : working directory. What folder should the command start in?
icon (str or list) : filename or (filename, index) (only for file sc)
What icon should be used for the shortcut
Returns:
None
>>> create_shortcut(r'c:\\tmp\\test.lnk',target='c:\\wapt\\waptconsole.exe')
"""
ext = os.path.splitext(path)[1].lower()
if ext == '.url':
with open(path, 'w') as shortcut:
shortcut.write('[InternetShortcut]\n')
shortcut.write('URL=%s\n' % target)
shortcut.write('IconFile="%s"\n' % icon)
shortcut.write('IconIndex=0\n') # ICI
else:
winshell.CreateShortcut(path, target, arguments, wDir, (icon, 0), '')# ET ICI
Il suffirait juste de faire ça (?) :
Code : Tout sélectionner
def create_shortcut(path, target='', arguments='', wDir='', icon='', index_icon=''):
r"""Create a windows shortcut
Args:
path (str) : As what file should the shortcut be created?
target (str): What command should the desktop use?
arguments (str): What arguments should be supplied to the command?
wdir (str) : working directory. What folder should the command start in?
icon (str or list) : filename or (filename, index) (only for file sc)
What icon should be used for the shortcut
Returns:
None
>>> create_shortcut(r'c:\\tmp\\test.lnk',target='c:\\wapt\\waptconsole.exe')
"""
ext = os.path.splitext(path)[1].lower()
index_icon = index_icon if os.path.splitext(icon)[1].lower() == '.dll' else 0
if ext == '.url':
with open(path, 'w') as shortcut:
shortcut.write('[InternetShortcut]\n')
shortcut.write('URL=%s\n' % target)
shortcut.write('IconFile="%s"\n' % icon)
shortcut.write('IconIndex="%s"\n' % index_icon)
else:
winshell.CreateShortcut(path, target, arguments, wDir, (icon, index_icon), '')
Merci d'avance !