I am fairly new to Python and have been trying to make a program that will open the "Minecraft launcher" for me.
However, the new launcher .exe
file is blocked as it is located in the windowsapp file which requires a lot of faffing about that I would rather avoid, so instead I was hoping to see if I could open the desktop shortcut instead to open the launcher directly?
This code so far doesn't work as it gives me the error:
OSError: [WinError 193] %1 is not a valid Win32 application
import time
import subprocess
subprocess.Popen('C:/Users/(my username)/Desktop/Minecraft Launcher.lnk')
I have tried subprocess.call
however that doesn't seem to work either.
.lnk
files are interpreted by the shell. So, enable the shell:
subprocess.call("C:\\Users\\My Username\\Desktop\\Minecraft Launcher.lnk", shell=True)
As a side note, the shell is one of the very few things in Windows that insists on backslashes.