gpt4 book ai didi

VBscript - "The system cannot find the file specified"

转载 作者:行者123 更新时间:2023-12-03 06:44:34 33 4
gpt4 key购买 nike

我正在尝试编写一个简短的 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/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com