我正在尝试创建一个脚本来运行我在特定项目中使用的所有工具(dor 实例、gulp、phpstorm、php 服务器等)
我想运行快捷方式而不是可执行文件。我可以看到在 Windows 中实现它的两种可能方法:
不幸的是,我都失败了:
1) WshShell 触发 .lnk 文件,但我找不到替代方法:
为此,我正在尝试编写 .cmd 文件或 .vbs
但是,我在各个方面都有问题。
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad.exe" ' Works alright
WshShell.Run "C:\Users\eugene\Desktop\gulp EngMe.lnk" ' got an Exception: Unknown Exception
2) .cmd 脚本等待关闭之前启动的应用程序:
@rem urls and filesystem shortcuts start alright:
"C:\Users\eugene\Desktop\8000.url"
"C:\Users\eugene\Desktop\project_folder.lnk"
@rem the following two commands are starting sequentially, when the previous one has closed.
"notepad.exe"
@rem shortcut to %windir%\system32\notepad.exe:
"C:\Users\eugene\Desktop\Notepad_.lnk"
我做错了什么,还有其他方法可以做我正在尝试的事情吗?
最佳答案
带空格的路径在输入 "quoted"
时必须是 .Run
,所以:
WshShell.Run """C:\Users\eugene\Desktop\gulp EngMe.lnk"""
会工作得很好。
关于batch-file - 如何在 Windows 中使用脚本运行多个快捷方式(.lnk 文件)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36591462/