Calling START command to invoke command with a Path containing spaces

T

TJT

Let's say for example that I have a directory named "D:\Test Folder" (with
an embedded space). In this folder is a bat file named test.bat. Here is
the contents of test.bat:
@echo off
echo p1=%1
echo p2=%2
echo p3=%3

If I were to execute this using the following CALL command
CALL "D:\Test Folder\test" "Parm 1" "Parm 2" "Parm 3"
Everything works OK.

Now on the other hand if I try to execute the following START command
start "TestWindowTitle" "D:\Test Folder\test" "Parm 1" "Parm 2" "Parm 3"
I get the following error message in the newly spawned window:
'D:\Test' is not recognized as an internal or external command,
operable program or batch file.

Can someone tell me what I'm doing wrong?

Any help would be greatly appreciated.
 
M

Michael D. Ober

Are you sure you have 'TestWindowTitle' in quote marks. The start command
uses the first quoted string as the window title.

Mike Ober.
 
T

TJT

Yes - it is within double-quotes "TestWindowTitle". The newly spawned
window has the correct title.
--Tom
 
G

Garry Deane

Let's say for example that I have a directory named "D:\Test Folder" (with
an embedded space). In this folder is a bat file named test.bat. Here is
the contents of test.bat:
@echo off
echo p1=%1
echo p2=%2
echo p3=%3

If I were to execute this using the following CALL command
CALL "D:\Test Folder\test" "Parm 1" "Parm 2" "Parm 3"
Everything works OK.

Now on the other hand if I try to execute the following START command
start "TestWindowTitle" "D:\Test Folder\test" "Parm 1" "Parm 2" "Parm 3"
I get the following error message in the newly spawned window:
'D:\Test' is not recognized as an internal or external command,
operable program or batch file.

Can someone tell me what I'm doing wrong?

Any help would be greatly appreciated.

It's START that's at fault. It get's confused when the program is
quoted then followed by more quoted strings. The easiest? fix is to
use the SFN of the program path so there's no need to quote it:

start "TestWindowTitle" D:\testfo~1\test "Parm 1" "Parm 2" "Parm 3"

Garry
 
J

Jerold Schulman

I confirm the bug.

A workaround is:

start "TestWindowTitle" /D "D:\Test Folder" test.bat "Parm 1" "Parm 2" "Parm 3"


OR

pushd "D:\Test Folder"
start "TestWindowTitle" test.bat "Parm 1" "Parm 2" "Parm 3"
popd



Let's say for example that I have a directory named "D:\Test Folder" (with
an embedded space). In this folder is a bat file named test.bat. Here is
the contents of test.bat:
@echo off
echo p1=%1
echo p2=%2
echo p3=%3

If I were to execute this using the following CALL command
CALL "D:\Test Folder\test" "Parm 1" "Parm 2" "Parm 3"
Everything works OK.

Now on the other hand if I try to execute the following START command
start "TestWindowTitle" "D:\Test Folder\test" "Parm 1" "Parm 2" "Parm 3"
I get the following error message in the newly spawned window:
'D:\Test' is not recognized as an internal or external command,
operable program or batch file.

Can someone tell me what I'm doing wrong?

Any help would be greatly appreciated.


Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
 

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