Redirect output from "start"-ed console

Jun 1, 2008
30
0
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.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
---- 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
 
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>
 
Similar threads
Thread starter Title Forum Replies Date
D Start program without waiting and redirect output Support 6
J Can you redirect output to printer device with echo? Support 1
B How to? redirect a bunch of loop Support 4
JohnQSmith WAD DO and escaped redirect characters Support 6
nickles Redirect bug? Support 4
C redirect with TCMD 8.02 Support 4
A How to? TEE - duplicate output to STDERR Support 3
FreezerBurnt ANSI Prompt messes up list output. Support 39
Ó Recent git output not shown on TCC Support 1
Peter Murschall TEE cannot handle Unicode output Support 2
C TEE command appending null characters to output Support 6
Jesse Heines webform output different in ver. 26 than ver. 25 Support 2
vefatica Piping the output of a DO loop. Support 4
vefatica TCMD output invisible on Win10 Support 22
B How can TCC make an output as a part of command string Support 2
Enigma Take Command 23 duplicates output Support 0
Joe Caverly Works with CMD.EXE, no output with TCC.EXE Support 7
S Output from debugger Support 4
M TCC incorrect dir output since Windows 1803 Support 6
A WAD Output redirection to IF block fails with "unbalanced brackets" Support 7
P Scrollable colored output Support 3
scottb How to? ipconfig output in current window Support 4
David McClelland TEE command puts it's output file in c:\ Support 4
vefatica How to? TPIPE ... see output right away? Support 4
T Fixed Unnecessary debug output Support 3
JohnQSmith Weird DIR output (missing lines) Support 1
J WAD Output redirection in tcexit looses data Support 31
vefatica Console output slower that before Support 8
Mordachai How to capture all console output from a TCMD session? Support 4
C Output continues after Ctrl-Break Support 8
Steve Pitts WAD Strange output from DEL of a non-existent directory Support 7
I perl output is not visible Support 4
I v16 - cls corrupts output stream Support 7
D Fixed Minor problem: output not alligned in the tree command Support 1
vefatica WAD IDE, output window to foreground Support 3
R WAD Strange output from "memory" command Support 1
A How to? Set up a log file for all command output Support 3
A How to? Use TEE with .NET output Support 6
T How to? Logging Output from External Programs Support 4
Frank output of @ipaddress/@ipname Support 1
dcantor Unidentifiable output Support 16
Stefano Piccardi forum software writes debugging output Support 5
Stefano Piccardi TCC 13 vs. TCC 14 different FFIND /E"d$" output Support 1
H TPIPE: /FILTER and /OUTPUT unexpected incompatibility Support 6
Stefano Piccardi issue: redirecting GOSUB output Support 11
A How to? Pass output from ffind to another command in a BTM file Support 5
A How to? How to enable UTF-8 output in tcmd.ini Support 9
W Ascii character output Support 12
S SELECT DEL (*D.DLL) - output curious Support 8
T eval[] crashes with negative binary output Support 1

Similar threads