How to launch a Window's shortcut using Python
10,901
The Python os.startfile
function should work fine, but you need to specify a .lnk
extension to be a valid Windows shortcut file:
import os
os.startfile (r"D:\games\blender.lnk")
If you need to wait for the application to complete before continuing, then a different approach would be needed as follows:
import win32com.shell.shell as shell
import win32event
se_ret = shell.ShellExecuteEx(fMask=0x140, lpFile=r"D:\games\blender.lnk", nShow=1)
win32event.WaitForSingleObject(se_ret['hProcess'], -1)
Author by
Yan Godara
Updated on June 19, 2022Comments
-
Yan Godara almost 2 years
I want to launch a shortcut named
blender.ink
located at"D://games//blender.ink"
. I have tryed using:-os.startfile ("D://games//blender.ink")
But it failed, it only launches exe files.