0

Im writing a small VBScript that i will pass a file path to. It works fine when the file name has no spaces but not when it does.

As far as I can tell, this is the offending line:

If util.Run("c:\program files (x86)\microsoft office\office14\PPTVIEW.exe " & WScript.Arguments(1)) = True Then
...perfomrm tasks...
End If

I have tried putting quotes around WScript.Arguments(1) but i still get errors. Any ideas on how I can get it to work?

4

2 回答 2

3

您需要在文件路径字符串的每一端插入引号——现有的引号只是通知脚本引擎它包含一个字符串。您可以通过附加 Chr(34) 或添加两个双引号来执行此操作,如下所示:

If util.Run("""c:\program files (x86)\microsoft office\office14\PPTVIEW.exe"" " &    WScript.Arguments(1)) = True Then
    ...perfomrm tasks...
End If
于 2012-07-24T10:21:38.807 回答
1

以下代码设置可执行文件的路径以及引号内的参数:

If util.Run("""c:\program files (x86)\microsoft office\office14\PPTVIEW.exe"" """ & WScript.Arguments(1) & """") = True Then
...perfomrm tasks...
End If
于 2012-07-24T10:23:52.283 回答