WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DOS

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Can't Run DOS BAT File with double-quoted Argument in NT4

Keywords: 	  double quote

Question:

Why doesn't the following line work in a script?
	Run( `c:\bat\DelTree.bat`, `"C:\My Files"` )
The equivalent command line works fine; i.e.,
	C:\> c:\bat\DelTree.bat "C:\My Files"
When I run this from a script, nothing happens except a black DOS window flashes briefly.

I'm running this under NT 4.0. It works fine under Win95.

I have a simplifed test file called XECHO.BAT which I've modified to the following to show more clearly what is happening:

	@echo off
	echo arg1 = %1 
	echo arg2 = %2
	pause
When I used the first test case,
runwait("xecho.bat", "AAA")
it echoed
	arg1 = AAA
	arg2 =
as expected. When I ran the second test case,
	runwait("xecho.bat", "My Files")
it echoed
	arg1 = My
	arg2 = Files
which is also what I expected. But when I ran the third test,
	runwait("xecho.bat", '"My Files"')
I again got a quick flash of a DOS window with some error text in it. To read the text, I had to put it in a tight loop; i.e.,
	:loop
	runwait("xecho.bat", '"My Files"')
	goto loop
The error text was "The name specified is not recognized as an internal or external command, operable program or batch file."

What I *should* have gotten, of course, would be,

	arg1 = "My Files"
	arg2 = 
and this is what I get if I run the batch file from a command line. This is the reult I need for my batch file to be able to accept filenames containing spaces.

Answer:

I played around with NT 4.0 for a while. Interesting results.

If you go to a console window and run:

	c:\temp>command.com /c xecho.bat "MY FILES"
It gets it WRONG. It actually gets the same results as
	Run('command.com','/c xecho.bat "MY FILES"')
NT 4.0 command processor is not processing command line arguments properly. I am absolutely amazed that no one has noticed this before. I'll geck around and see if there are any fixes anyplace.

Looks like its workaround time.

My best guess at a solution is to use FileNameShort() to convert the long filename to a short file anme and pass that instead.


Article ID:   W12872
Filename:   Bug in NT 4 when Passing Params to DOS Bat.txt
File Created: 1999:04:15:16:50:12
Last Updated: 1999:04:15:16:50:12