Good day...
I've been playing with samples and banging on my head on this, and have given in to ask for help...sigh
From my C# application, I need to run an exe that lives in the %WINDIR% directory, with arguments, and capture the output.
Below is a snippet of what I've tried. Right now, I just want to show a messagebox with the output. The issue that I'm having is ischk.exe is popping up with "Invalid argument". However, if I run the same command from CMD it works fine.
Any help I can get from the gurus would be most appreciated!!! Thanks in advance!
//Create and start the ischk.exe process System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("ischk.exe"); psi.Arguments = "-s " + strenv; psi.RedirectStandardOutput = true; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; psi.UseShellExecute = false; System.Diagnostics.Process ischk; ischk = System.Diagnostics.Process.Start(psi); ischk.WaitForExit(); ////Create a streamreader to capture the output of ischk //System.IO.StreamReader ischkout = ischk.StandardOutput; ischk.WaitForExit(); if (ischk.HasExited) { string output = ischkout.ReadToEnd(); MessageBox.Show(output); }