Redirect output from "start"-ed console

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Jun 1, 2008
30
0
#1
I have a test.bat which contains just this: "echo blah". When I run
Code:
test.bat > output.txt
I get output.txt containting "blah". How do I redirect the output if test.bat is launched with "start":
Code:
start "test" test.bat > output.txt
I get no output.txt. I tried escaping the ">" with "^" and "\", but no dice.
 
#4
---- Original Message ----
From: element
| I have a test.bat which contains just this: "echo blah". When I run
| Code:
| test.bat > output.txt
| I get output.txt containting "blah". How do I
| redirect the output if test.bat is launched with "start":
| Code:
| start "test" test.bat > output.txt
|
| I get no output.txt. I tried
| escaping the ">" with "^" and "\", but no dice.

This works:
start "title" /pgm "%_cmdspec" /c test > output.txt

Note the use of /pgm to force the quoted argument to be considered as the program to be executed; /c to make the session terminate upon command completion. The START command considers the first string following /PGM to be the file specification of the program to be executed, and everything thereafter as parameters to be passed to the program to be executed.
|--
HTH, Steve
 
#6
It works for me, although I'm not sure why:

HTML:
C:\Junk>dir

 Volume in drive C is OS             Serial number is 1ce5:1203
 Directory of  C:\Junk\*

 4/29/2011  11:23p        <DIR>    .
 4/29/2011  11:23p        <DIR>    ..
 4/29/2011  11:22p             11  Test.bat
                11 bytes in 1 file and 2 dirs    4,096 bytes allocated
   152,002,830,336 bytes free

C:\Junk>type Test.bat
echo blah

C:\Junk>start "%_cmdspec" /c test.bat > output.txt

C:\Junk>dir

 Volume in drive C is OS             Serial number is 1ce5:1203
 Directory of  C:\Junk\*

 4/29/2011  11:23p        <DIR>    .
 4/29/2011  11:23p        <DIR>    ..
 4/29/2011  11:23p              6  output.txt
 4/29/2011  11:22p             11  Test.bat
                17 bytes in 2 files and 2 dirs    8,192 bytes allocated
   152,002,756,608 bytes free

C:\Junk>type output.txt
blah

C:\Junk>