Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure that is even possible - well at least not using some plain simple API.</p> <p><em>Please note that I have not found (although I tried) any information on the web that <strong>directly confirms</strong> that, but here is how I come to this conclusion.</em></p> <p>The console in Windows is its own subsystem, managed by <code>csrss.exe</code> (and starting with Windows Vista also <code>conhost.exe</code>, but I digress). It has it's own set APIs (<code>AttachConsole</code>, <code>WriteConsole</code>, etc.) and you can only have one "console" per process.</p> <p><code>CMD.EXE</code> on the other hand is just another console mode application, that just happens to use the console and being launched it a console window. You can observe this effect, by launching a different console mode application and watch the process tree in e.g. Process Explorer: there is no CMD.EXE parent process (but rather it is Explorer or whatever you used to start it - including of course CMD.EXE).</p> <p>Thus far I was trying to show the difference between "the console" and <code>CMD.EXE</code>, batch files, or console mode applications in general.</p> <p>So when in <code>CMD.EXE</code> you use <code>&gt; CON</code> you are actually causing the same effect as doing a write to <code>CONOUT$</code> in native applications (or your typical write to <code>/dev/console</code> on a UNIX-like OS). There doesn't seem to be a direct equivalent for managed code, as <code>Console.Out</code> and <code>Console.Error</code> equal <code>stdout</code> and <code>stderr</code> in native applications (or <code>1</code> and <code>2</code> as file descriptors in <code>CMD.EXE</code>).</p> <p>Having all that said, when you start a process you're only enabled to redirect it's standard output and standard error streams, but not (per se) the messages it writes to the console (or <code>CONOUT$</code> handle). I guess that would be the same as trying to redirect output that a process writes to some file, which is also not (generically) possible.</p> <p>You could possible achieve this using some hooking or injecting something inside the child process to grab the console output.</p> <p>Being not able to easily do this, is also (one of) the reason(s) why writing a complete terminal (i.e. console window, not <code>CMD.EXE</code>!) replacement for Windows is not easily possible and requires some hacks or workarounds.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload