1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect output from "start"-ed console

Discussion in 'Support' started by element, Apr 29, 2011.

  1. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    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.
     
  2. David Marcus

    Joined:
    Jun 4, 2008
    Messages:
    646
    Likes Received:
    1
    Maybe

    start "%_cmdspec" /c test.bat ^> output.txt
     
  3. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    0
    Still nothing. BTW, I believe the first param for "start" would be the console title:
    Code:
    start "test" "%_cmdspec" /c test.bat ^> output.txt
     
  4. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    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
     
  5. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    0
    Yes, it does, thanks. It even works from a batch file, without escape characters.
     
  6. David Marcus

    Joined:
    Jun 4, 2008
    Messages:
    646
    Likes Received:
    1
    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>
     

Share This Page