# Have Cook Commandlet output go to stdout?

**URL:** <https://forums.unrealengine.com/t/have-cook-commandlet-output-go-to-stdout/334108>\
**Category:** Platform & Builds\
**Tags:** commandlet, command-line, unreal-engine, cook, question\
**Created:** [October 2, 2015, 8:35pm UTC](https://forums.unrealengine.com/t/have-cook-commandlet-output-go-to-stdout/334108 "2015-10-02T20:35:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_2f0c4948](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2f0c4948](https://forums.unrealengine.com/u/anonymous_user_2f0c4948)\
**Post date:** [October 2, 2015, 8:35pm UTC](https://forums.unrealengine.com/t/have-cook-commandlet-output-go-to-stdout/334108/1 "2015-10-02T20:35:48Z")

</div>

We are currently experimenting with using the `cook` commandlet to cook assets on our build system.

The commandlet is run from a CMD shell on Windows but right after starting it does open its own console window where it displays its output.  
Since we are running it from a command line environment such as a build server we want it to output directly to the initial stdout channel instead of this additional console window.

Looking at the `FEngineLoop::PreInit` method, it looked like adding `-stdout` as a command line switch on the commandlet would cause it to really use the initial stdout channel but this does not change a thing and looking at the code further seems to indicate that the whole commandlet actually redirects all “stdout” output to its own custom output window.

Is there a way to disable this highly undesirable behaviour?  
There is no need to open an additional console window when already launched from a command line shell. Also, many build environments do actually not allow windows to be opened (when run as services for instance on Windows) so I suspect that this might cause issues in these cases.

---

<div class="post-metadata">

**Author:** ![theonecalledtom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@theonecalledtom](https://forums.unrealengine.com/u/theonecalledtom)\
**Post date:** [January 20, 2016, 12:56am UTC](https://forums.unrealengine.com/t/have-cook-commandlet-output-go-to-stdout/334108/2 "2016-01-20T00:56:44Z")

</div>

This works in C#, you could write your own wrapper that handles output as you want (in this case it directs it to Log, after the invoke which would probably be needless in a simple console app.

```
void StartProcess(string toolExeOrBatch, string cmdline)
{
            System.Diagnostics.ProcessStartInfo oStartInfo = new System.Diagnostics.ProcessStartInfo();
            oStartInfo.FileName = toolExeOrBatch;
            oStartInfo.Arguments = cmdline;
            oStartInfo.ErrorDialog = true;
            oStartInfo.RedirectStandardOutput = true;
            oStartInfo.UseShellExecute = false;
            oStartInfo.CreateNoWindow = true;
            System.Diagnostics.Process process = System.Diagnostics.Process.Start(oStartInfo);
            process.OutputDataReceived += ToolOutputHandler;
            process.BeginOutputReadLine();

            while (!process.HasExited)
            {
                Application.DoEvents(); // This keeps your form responsive by processing events
            }

            bool bSuccess = process.ExitCode != 0;
            if(bSuccess)
            {
                Log("Calling External Process- Completed!");
            }
            else
            {
                Log("Calling External Process- FAILED! Return code: " + process.ExitCode.ToString());
            }
            process.Close();

................

private void ToolOutputHandler(object sendingProcess, System.Diagnostics.DataReceivedEventArgs outLine)
        {
            if (richTextBox_Output.InvokeRequired)
            {
                richTextBox_Output.BeginInvoke(
                        new System.Diagnostics.DataReceivedEventHandler(ToolOutputHandler), new[] { sendingProcess, outLine }
                    );
            }
            else
            {
                if (outLine.Data != null)
                {
                    Log(outLine.Data);
                }
            }
        }

```
