带空格的 VB 脚本和文件名 [英] VB Script and filename with space

查看:68
本文介绍了带空格的 VB 脚本和文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个 VBS 文件来打开6 May"文件夹,内容如下

I wrote a VBS file to open the "6 May" folder with following content

path = "F:\Test\2010\May\6 May"
Set Sh = CreateObject("WSCript.Shell")
Sh.Run ""path"",3,True
Set Sh = Nothing 

但是在执行此操作时出现以下错误

However on executing this I am getting following error

脚本:F:\Sperry\2010\May_06 May\open.vbs线路:4字符:10错误:预期的语句结束代码:800A0401来源:Microsoft VBScript 编译错误

Script: F:\Sperry\2010\May_06 May\open.vbs Line: 4 Char: 10 Error: Expected end of statement Code: 800A0401 Source: Microsoft VBScript compilation error

有人可以帮我吗?

推荐答案

您的 ""path"" 语法不正确.要在 VBScript 中连接字符串,您需要使用 & 运算符.此外,要将引号字符指定为字符串的一部分,您需要将其加倍.因此,您的脚本应如下所示:

Your ""path"" syntax is incorrect. To concatenate strings in VBScript, you need to use the & operator. Also, to specify a quote character as part of the string, you need to double it. So, your script should look like this:

path = "F:\Test\2010\May\6 May"
Set Sh = CreateObject("WSCript.Shell")
Sh.Run """" & path & """", 3, True
Set Sh = Nothing

这篇关于带空格的 VB 脚本和文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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