使用子进程打开Windows快捷键文件`.lnk`
我是Python的新手,并且一直在尝试制作一个将为我打开“ Minecraft Launcher”的程序。
但是,上下文
,新的启动器.exe
文件被阻止,因为它位于WindowsApp文件中,它需要大量的操作,我宁愿避免使用,因此我希望我是否可以打开桌面快捷方式而不是直接打开发射器?
到目前为止,
此代码无法正常工作,因为它给了我错误:
OSError: [WinError 193] %1 is not a valid Win32 application
我尝试过的代码
import time
import subprocess
subprocess.Popen('C:/Users/(my username)/Desktop/Minecraft Launcher.lnk')
subprocess.call
,但是这似乎也行不通。
I am fairly new to Python and have been trying to make a program that will open the "Minecraft launcher" for me.
Context
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?
Error
This code so far doesn't work as it gives me the error:
OSError: [WinError 193] %1 is not a valid Win32 application
Code
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.lnk
文件由外壳解释。因此,启用外壳:作为旁注,壳是窗户中坚持反斜线的几件事之一。
.lnk
files are interpreted by the shell. So, enable the shell:As a side note, the shell is one of the very few things in Windows that insists on backslashes.