views:

56

answers:

3

Hi everyone,

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?

A: 

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.

Pekka
A: 

have you tried

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

?

Philipp
It worked fine..... :-D Thanks.........
Kush
+2  A: 

Try doing this:

cmds = WshShell.RUN("""E:\My Folder\RunScript.bat\""", 0, True)
Davide
It worked fine..... :-D Thanks.........
Kush