XP problem passing command arguments with spaces

R

Ron G

In a VB6 application, any file path with spaces that is passed from
WindowsXP file explorer will not open in the application. I get a "File
does not exist". Yet I can open that same file using a common dialog
box in the application. I can also type the path as an argument from a
dos prompt.

MyApplication c:\directory with spaces\test.txt

This works from a DOS window but if I double click on the file I get the
"File does not exist". If I take the spaces out of the path it works
fine. In window 2000 and before I did not have a problem. Something
has changed in how XP passes arguments from the file manager.
 
P

Pegasus \(MVP\)

Ron G said:
In a VB6 application, any file path with spaces that is passed from
WindowsXP file explorer will not open in the application. I get a "File
does not exist". Yet I can open that same file using a common dialog
box in the application. I can also type the path as an argument from a
dos prompt.

MyApplication c:\directory with spaces\test.txt

This works from a DOS window but if I double click on the file I get the
"File does not exist". If I take the spaces out of the path it works
fine. In window 2000 and before I did not have a problem. Something
has changed in how XP passes arguments from the file manager.

Surround your file names with double quotes, e.g.
"c:\directory with spaces\test.txt". BTW, DOS is an
operating system, like Linux or Windows. There is no
DOS under Windows. I suspect you mean the "Command
Prompt" when you write "DOS window".
 
W

Wesley Vogel

What is WindowsXP file explorer? Windows Explorer (explorer.exe)?

What is a DOS window? Command.com? Use cmd.exe instead.

Use 8.3 names with no spaces or use quotes.

"c:\directory with spaces\test.txt"

You have to use quotes with some commands with cmd.exe, especially if the
path contains a white space.

<quote>
Remarks
Using multiple commands
* You can use multiple commands separated by the command separator && for
string, but you must enclose them in quotation marks (for example,
"command&&command&&command").

Processing quotation marks
If you specify /c or /k, cmd processes the remainder of string and quotation
marks are preserved only if all of the following conditions are met:

* You do not use /s.
* You use exactly one set of quotation marks.
* You do not use any special characters within the quotation marks (for
example: &<>( ) @ ^ |).
* You use one or more white-space characters within the quotation marks.
* The string within quotation marks is the name of an executable file.

If the previous conditions are not met, string is processed by examining the
first character to verify whether or not it is an opening quotation mark. If
the first character is an opening quotation mark, it is stripped along with
the closing quotation mark. Any text following the closing quotation marks
is preserved.

File and directory name completion correctly processes file names that
contain white space or special characters if you place quotation marks
around the matching path.

The following special characters require quotation marks: & < > [ ] { } ^ =
; ! ' + , ` ~ [white space]

If the information that you supply contains spaces, use quotation marks
around the text (for example, "Computer Name").
<quote>
from CMD...
Paste the following line into Start | Run and click OK...

hh ntcmds.chm::/cmd.htm

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
 
R

Ron G

I figured it out. Explorer.exe passes a string in quotes if the path
has white spaces in it. Those quotes must be removed before passing the
string to the fileopen statement.
 

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