Shell Command Doesn't Like Spaces?

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.
 
D

Douglas J. Steele

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.
 
S

Stefan Hoffmann

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 <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top