Shell Command Doesn't Like Spaces?

  • Thread starter Thread starter LarryP
  • Start date Start date
L

LarryP

I've encountered a problem with a shell command not liking filepaths with
spaces. For example, Shell("c:\My Special Folder\Do This.bat") fails, but
Shell("c:\MySpecialFolder\DoThis.bat") works. Anybody know a solution that
will make the names with spaces acceptable to the Shell command? I don't
always have the power to change the file or folder names.
 
Try

Shell("""c:\My Special Folder\Do This.bat""")

That's three double quotes in a row, rather than just one. That has the
effect of putting a double quote before and after the string that's passed
to the Shell function.
 
hi Larry,
I've encountered a problem with a shell command not liking filepaths with
spaces. For example, Shell("c:\My Special Folder\Do This.bat") fails, but
Shell("c:\MySpecialFolder\DoThis.bat") works. Anybody know a solution that
will make the names with spaces acceptable to the Shell command? I don't
always have the power to change the file or folder names.
The command line parser uses spaces as separators, so when they are part
of a file name you need to enclose the entire token into quotation marks:

Shell """c:\My Special Folder\Do This.bat"""

mfG
--> stefan <--
 
Back
Top