在VB6中,在文件夹名称包含空格的路径上执行.bat文件时出现问题

时间:2010-09-09 10:22:23

标签: vb6 shellexecute filepath

我正在尝试使用以下代码在VB6(静默窗口模式)中执行.bat文件。

Set WshShell = CreateObject("WScript.Shell")

cmds = WshShell.RUN("E:\My Folder\RunScript.bat", 0, True)

Set WshShell = Nothing

如果'My Folder'中没有空格,那么事情就会很好。但是如果遇到这样的空格,调用就会失败。我该如何解决这个问题?

3 个答案:

答案 0 :(得分:4)

尝试这样做:

cmds = WshShell.RUN("""E:\My Folder\RunScript.bat\""", 0, True)

答案 1 :(得分:0)

我对WSH知之甚少,但尝试添加单引号:

cmds = WshShell.RUN("'E:\My Folder\RunScript.bat'", 0, True)

如果RUN将命令传递给其他某个实例,他们可能会这样做。

或者,如果你想走丑陋的路线,你可以尝试找出目录的8.3名称(使用dir),然后指定。

答案 2 :(得分:0)

你试过吗

cmds = WshShell.RUN("""E:\My Folder\RunScript.bat""", 0, True)

相关问题