0

i have the following problem:

My programm executes a command line command which starts a different programm and passes some parameters.

Once the other programm is done, it opens a cmd-window, which only contains a status message. (like "no errors" or "completed task but some errors were encountered"

what I want to do now is:

  1. get the message from the new cmd window. (The other programm has a variable execution time. It might take seconds or minutes for the cmd window to appear.)

  2. create a pop up window in the form of a message box that contains the message.

  3. close the new cmd window

I managed to get the output of a cmd window that I started in my programm with process.StandardOutput.ReadToEnd() but I couldn't find a way to get the output of an external cmd window I hope you can help me.

Daniel
  • 1
  • 2
  • You might have some lock with P/Invoking with the [`AttachConsole`](https://learn.microsoft.com/en-us/windows/console/attachconsole) Win32 API. I used it for a similar reason in the past. You might find something to start with [here](https://social.msdn.microsoft.com/Forums/vstudio/en-US/c6b014b5-6a92-49b9-8c50-bd7235c745c2/reatach-to-main-console-window-attachconsole-freeconsole-?forum=netfxbcl) (At "duplicate voters" this is not the same as launching a program in the _same_ console window and redirecting it's output.) – Christian.K Aug 30 '22 at 16:20

1 Answers1

1

Alter your command line such that the output is written into a file, then read the file.

Christian O.
  • 514
  • 1
  • 5
  • 20