Search code examples
vb6shellexecutefilepath

Problem executing a .bat file at a path where folder name has spaces, in VB6


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?


Solution

  • Try doing this:

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