VBscript - “系统找不到指定的文件" [英] VBscript - "The system cannot find the file specified"

查看:135
本文介绍了VBscript - “系统找不到指定的文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个简短的 VBScript,它会打开calc.exe"和wordpad.exe".问题是 VBScript 不允许我打开wordpad.exe".我尝试以管理员身份运行脚本,但这没有帮助.

I'm trying to write a short VBScript, which opens "calc.exe" and "wordpad.exe". Well the problem is that VBScript won't let me open "wordpad.exe". I've tried to run the script as an admin, but this doesn't helped.

我的脚本如下所示:

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) 

我也尝试过这样定义路径:

I've also tried to define the path like this:

WSHShell.Run ""C:\Program Files\Windows NT\Accessories\wordpad.exe""

也不行.我收到消息预计语句结束"

Also not working. I'm getting the message "Expected end of statement"

有没有办法通过路径打开wordpad.exe"?

Is there a solution to open "wordpad.exe" by its path?

亲切的问候

推荐答案

shell 使用空格/空格作为分隔符.因此需要引用包含空格/空格的路径.在 VBScript 字符串文字中引用 " 的方法是将它们加倍.所以:

The shell uses blanks/spaces as separators. So paths containing blanks/spaces need to be quoted. The way to quote " in VBScript string literals is to double them. So:

WSHShell.Run "C:\Program Files\Windows NT\Accessories\wordpad.exe"
==>
WSHShell.Run """C:\Program Files\Windows NT\Accessories\wordpad.exe"""

这篇关于VBscript - “系统找不到指定的文件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆