Skip to content

Commit 2945f42

Browse files
committed
Improvements for shortcuts to files that rely on other files inside their folder
1 parent caa47fb commit 2945f42

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ def create_file_shortcut(file_path, name: str, icon_path: str, icon_index: int =
4747
random_number_2 = str(random.randint(1000, 9999))
4848

4949
subprocess.call(f"md \"{working_folder}\\shortcuts\\", shell = True)
50-
open(working_folder + f"\\shortcuts\\file_shortcut_{random_number}.bat", "w", encoding = "utf8").write(f"chcp 65001 > nul\n\"{file_path}\"")
50+
open(working_folder + f"\\shortcuts\\file_shortcut_{random_number}.bat", "w", encoding = "utf8").write(f"chcp 65001 > nul\ncd \"{(file_path + random_number_2).replace(file_name + random_number_2, '')}\"\n\"{file_path}\"")
5151
open(working_folder + f"\\shortcuts\\file_shortcut_{random_number}.vbs", "w", encoding = "utf8").write(script_template_2.replace("(command)", f"\"\"{working_folder}\\shortcuts\\file_shortcut_{random_number}.bat\"\""))
5252

5353
shell = win32com.client.Dispatch("WScript.Shell")
5454
shortcut = shell.CreateShortCut(f"{working_folder}\\shortcut\\shortcut_{random_number}.lnk")
5555
shortcut.TargetPath = "C:\\Windows\\System32\\wscript.exe"
56-
shortcut.WorkingDirectory = (file_path + random_number_2).replace(file_name + random_number_2, "")
5756
shortcut.Arguments = f"\"{working_folder}\\shortcuts\\file_shortcut_{random_number}.vbs\""
5857
shortcut.IconLocation = f"{icon_path},{icon_index}"
5958
shortcut.save()

0 commit comments

Comments
 (0)