问题
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
Windows Script Host
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
OK
Can anyone help me in this?
回答1:
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
来源:https://stackoverflow.com/questions/2781995/vb-script-and-filename-with-space