Calling START command to invoke command with a Path containing spaces

  • Thread starter Thread starter TJT
  • Start date Start date
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.
 
Are you sure you have 'TestWindowTitle' in quote marks. The start command
uses the first quoted string as the window title.

Mike Ober.
 
Yes - it is within double-quotes "TestWindowTitle". The newly spawned
window has the correct title.
--Tom
 
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
 
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
 
Back
Top