I have a couple of old windows programs that we still need to use. Both are designed to run from batch files with command line options so using Process to start and monitor them works fine.
Both programs display progress windows after starting and I would like to hide those windows but they don't seem to respond to the Process setting that control window display.
ProcessStartInfo info = new ProcessStartInfo() {
FileName = appName,
Arguments = arguments,
RedirectStandardError = true,
RedirectStandardOutput = true,
WorkingDirectory = workingDirectory,
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden
};
StringBuilder errorData = new StringBuilder(OUTPUT_SIZE);
StringBuilder outputData = new StringBuilder(OUTPUT_SIZE);
using (Process process = new Process { StartInfo = info }) {
process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) => ErrorDataReceived(sender, e, errorData));
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) => OutputDataReceived(sender, e, outputData));
if (exited != null) {
process.EnableRaisingEvents = true;
process.Exited += exited;
}
process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
}
Is there another way to force the window hidden or do I just have to use them they way they are? I've done a bunch of searching but all the answer I find just use some variation of the code above.