batch-file - 如何在 Windows 中使用脚本运行多个快捷方式(.lnk 文件)?

标签 batch-file vbscript cmd wsh

我正在尝试创建一个脚本来运行我在特定项目中使用的所有工具(dor 实例、gulp、phpstorm、php 服务器等)

我想运行快捷方式而不是可执行文件。我可以看到在 Windows 中实现它的两种可能方法:

  1. 脚本语言
  2. cmd.exe

不幸的是,我都失败了:

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/

相关文章:

Java 找不到我的 main

powershell - 递归设置NTFS权限

svn - 如何将 SVN 存储库热复制到现有位置?

VBScript,冒号的用途?

java - ProcessBuilder 无法访问相对文件夹位置

windows - wscript exec cmd.exe/c不报错

c - 在命令提示符中监视 Netbeans C/C++ 的输出

windows - 批处理脚本 - 'If Statements' 中的通配符

dom - 在 VBScript 中捕获事件

python - 我怎样才能刮掉这个框架?