Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Redirecting output to the management command prompt.

Created: 27 Aug 2013

I am working on a product that runs on a customer facing live system. I am trying to implement console output to the PCA Remote Management Command Prompt so that an administrator can quickly connect and view status without interrupting the live GUI that can be seen by customers. Below is an example of an admittedly ugly attempt written in C#:

var processes = Process.GetProcessesByName("cmd");

if (processes.Length == 0)
   return;

var cmdProcess = processes[0];
_attached = AttachConsole((uint) cmdProcess.Id);

Console.WriteLine(@"Test");
Console.Error.WriteLine(@"Error Test");


[DllImport("kernel32", SetLastError = true)]

static extern bool AllocConsole();
 
This technique works when run on a local system by attaching to the first command prompt window it can find and writing to its StdOut stream. However it appears that PCA has redirected StdIn, StdOut and StdError which prevents this from working. Any help would be appriciated.
Operating Systems: