From ed4d4d81a653c2c900adc32abcb3eeec8db23dab Mon Sep 17 00:00:00 2001 From: will wade Date: Wed, 25 Oct 2023 15:36:27 +0100 Subject: [PATCH 1/2] dropping batch file creation - trying this instead. may go wrong if admin privs needed for powershell --- CreateGridset.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CreateGridset.py b/CreateGridset.py index 2ced1ac..a0989d1 100644 --- a/CreateGridset.py +++ b/CreateGridset.py @@ -40,12 +40,9 @@ def modify_gridset(gridset_path, LocalAppPath): shutil.rmtree(temp_dir) os.remove(gridset_path) - # Create a .bat file on the Desktop to act as a shortcut + # Create a shortcut file on the Desktop to act as a shortcut desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop') - bat_file = os.path.join(desktop, "Open Example AAC Helper Pages.bat") - - with open(bat_file, 'w') as f: - f.write(f'start "" "{new_gridset_dir}"') + os.system(f'powershell.exe $ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("{desktop}"); $s.TargetPath = "{new_gridset_dir}"; $s.Save()') if __name__ == "__main__": app_data_path = os.environ.get('APPDATA', '') # Changed to APPDATA From 818a7283c75edc6af1afeafe47be6b77915e0ebf Mon Sep 17 00:00:00 2001 From: will wade Date: Wed, 25 Oct 2023 15:38:32 +0100 Subject: [PATCH 2/2] quietly create shortcut --- CreateGridset.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CreateGridset.py b/CreateGridset.py index a0989d1..527e432 100644 --- a/CreateGridset.py +++ b/CreateGridset.py @@ -42,7 +42,11 @@ def modify_gridset(gridset_path, LocalAppPath): # Create a shortcut file on the Desktop to act as a shortcut desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop') - os.system(f'powershell.exe $ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("{desktop}"); $s.TargetPath = "{new_gridset_dir}"; $s.Save()') + exit_code = os.system(f'powershell.exe $ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("{desktop}"); $s.TargetPath = "{new_gridset_dir}"; $s.Save()') + if exit_code == 0: + #print("Shortcut successfully created.") + else: + #print("Failed to create shortcut.") if __name__ == "__main__": app_data_path = os.environ.get('APPDATA', '') # Changed to APPDATA