I/O redirection with start command.

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
I have tied quite a few combinations but I was not able to redirect I/O from a start command. Something like:

Code:
START X.EXE >&X.out
With X.EXE beeing a GUI applications writing stuff the the console I don´t want to see normally (but keeping the output in a log file would be nice for debugging).

I found an article on CMD but the ^ trick described won´t work with TCMD.

Any hints or is it hopeless?

Martin
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#2
> Code:
> ---------
> START X.EXE >&X.out
> ---------
> With X.EXE beeing a GUI applications writing stuff the the console I
> don´t want to see normally (but keeping the output in a log file would
> be nice for debugging).
If the GUI app is creating its own console, then it's hopeless. Redirection
is done by the command processor, not by Windows, and in this case the
command processor would never be invoked.

If X.EXE is not creating a new console (and is not really a GUI app), you'd
need to use a command group to capture the output of X.EXE. (In your
example above, you're redirecting the output of START, not the output of
X.EXE.)

Rex Conn
JP Software
 
#3
If the GUI app is creating its own console, then it's hopeless. Redirection
is done by the command processor, not by Windows, and in this case the
command processor would never be invoked.

If X.EXE is not creating a new console (and is not really a GUI app), you'd
need to use a command group to capture the output of X.EXE. (In your
example above, you're redirecting the output of START, not the output of
X.EXE.)
What if x.exe is a GUI app attaching to the console of its parent (AttachConsole(-1))? I wrote a little test (GUI) which did that and wrote "Hello world." both with WriteConsole() and with wprintf() (after setting up stdout). It works fine if I just give its name at the TCC command line but I can't figure out a way to capture its output (tried START /wait /b and command grouping). I couldn't do it with CMD either. Do you think it's possible?

The example the OP found was

Code:
START CMD /C essmsh CSR.build.outline.CSRCALC.mxl^>CSRCALC.LOG
But essmsh itself is a console app.
 
#5
If the GUI app is creating its own console, then it's hopeless.
The very first line printed is:

The launcher has determined that the parent process has a console and will reuse it for its own console output. Closing the console will result in termination of the running program.
So it seems that the app does indeed attach to to existing console. As do most Java applications.

If X.EXE is not creating a new console (and is not really a GUI app), you'd
need to use a command group to capture the output of X.EXE.
The following two options did not work out:

Code:
(START X.EXE ) >&X.out
START (X.EXE  >&X.out)
So I guess it is all down to some Window-Magic as vefatica pointed out and the whole stuff is hopeless.
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#6
The following two options did not work out:

Code:
(START X.EXE ) >&X.out
START (X.EXE  >&X.out)
So I guess it is all down to some Window-Magic as vefatica pointed out and the whole stuff is hopeless.
The only way it could work is if the GUI app did some custom magic at startup to use the console handles passed by TCC. (I've never seen *any* GUI app other than TCMD that does this.)
 
#7
The only way it could work is if the GUI app did some custom magic at startup to use the console handles passed by TCC.
Well, the console message suggest that some extras magic is done. It is ok, a very special case and not much one can do about.

(I've never seen *any* GUI app other than TCMD that does this.)
If you want to see one: http://netbeans.org/ ;-).