作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个简短的 VBScript,它会打开“calc.exe”和“wordpad.exe”。问题是 VBScript 不允许我打开“wordpad.exe”。我尝试以管理员身份运行该脚本,但这没有帮助。
我的脚本如下所示:
Set WshShell = WScript.CreateObject("WScript.Shell")
WSHShell.Run "C:\Program Files\Windows NT\Accessories\wordpad.exe"
WSHShell.Run "C:\Windows\System32\calc.exe"
x=msgbox("Test",4096,Test)
我也尝试过像这样定义路径:
WSHShell.Run ""C:\Program Files\Windows NT\Accessories\wordpad.exe""
也不起作用。我收到消息“预期语句结束”
有没有办法通过路径打开“wordpad.exe”?
亲切的问候
最佳答案
shell 使用空格作为分隔符。因此包含空格的路径需要用引号引起来。在 VBScript 字符串中引用 "
的方法是将它们加倍。因此:
WSHShell.Run "C:\Program Files\Windows NT\Accessories\wordpad.exe"
==>
WSHShell.Run """C:\Program Files\Windows NT\Accessories\wordpad.exe"""
关于VBscript - "The system cannot find the file specified",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33389660/
我是一名优秀的程序员,十分优秀!