From 98e7a579a6868fdf051f1f61923e51f1e80892e8 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Sun, 3 Oct 2021 13:13:35 -0400 Subject: [PATCH] Simplified support to be for local files only --- DemoPrograms/Demo_Make_Windows_Shortcut.pyw | 28 ++++++++------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/DemoPrograms/Demo_Make_Windows_Shortcut.pyw b/DemoPrograms/Demo_Make_Windows_Shortcut.pyw index ee18a8c0..9f0564e0 100644 --- a/DemoPrograms/Demo_Make_Windows_Shortcut.pyw +++ b/DemoPrograms/Demo_Make_Windows_Shortcut.pyw @@ -31,24 +31,18 @@ def create_shortcut(path, target='', icon=''): """ filename, ext = os.path.splitext(path) working_dir = os.path.dirname(filename) - if ext == 'url': - shortcut = file(filename, 'w') - shortcut.write('[InternetShortcut]\n') - shortcut.write('URL=%s' % target) - shortcut.close() + shell = Dispatch('WScript.Shell') + shortcut_filename = filename + ".lnk" + shortcut = shell.CreateShortCut(f'{shortcut_filename}') + target_path = f'{target}' + shortcut.Targetpath = target_path + shortcut.Arguments = f'"{path}"' + shortcut.WorkingDirectory = working_dir + if icon == '': + pass else: - shell = Dispatch('WScript.Shell') - shortcut_filename = filename + ".lnk" - shortcut = shell.CreateShortCut(f'{shortcut_filename}') - target_path = f'{target}' - shortcut.Targetpath = target_path - shortcut.Arguments = f'"{path}"' - shortcut.WorkingDirectory = working_dir - if icon == '': - pass - else: - shortcut.IconLocation = icon - shortcut.save() + shortcut.IconLocation = icon + shortcut.save() return shortcut_filename