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

发布于 2024-09-18 13:14:36 字数 273 浏览 2 评论 0原文

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

Set WshShell = CreateObject("WScript.Shell")

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

Set WshShell = Nothing

如果“我的文件夹”中没有空间,一切工作绝对正常。但如果遇到这样的空间,调用就会失败。我该如何解决这个问题?

I'm trying to execute a .bat file in VB6 (silent window mode) with following code.

Set WshShell = CreateObject("WScript.Shell")

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

Set WshShell = Nothing

Things work absolutely fine if there's no space in 'My Folder'.but call fails if such a space is encountered. How can I solve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

[旋木] 2024-09-25 13:14:36

尝试这样做:

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

Try doing this:

cmds = WshShell.RUN("""E:\My Folder\RunScript.bat\""", 0, True)
我最亲爱的 2024-09-25 13:14:36

我对 WSH 不太了解,但尝试添加单引号:

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

如果 RUN 将命令传递到其他实例,它们可能会起作用。

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

I don't know much about WSH, but try adding single quotes:

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

They may do the trick if RUN passes the command on to some other instance.

Alternatively, if you want to go the ugly route, you could try finding out the 8.3 name of the directory (using dir), and specify that.

笑梦风尘 2024-09-25 13:14:36

你尝试过吗

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

have you tried

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

?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文