I'm using ASP.NET and want to execute an MSDOS executable with some parameters like this example: software.exe
-i -x fileIn.htm fileOut.htm
How do I use System.Diagnostic.Process to execute this .exe with parameters? Could you give me the code lines with this example?
Thanks for your answer.
The Process class has a StartInfo property that is used to specify the behavior of your newly created process. The following code starts the command prompt, passing "/?" as a parameter, to show the associated help. It redirects the output so we can get it and show it on the page:
Process p = new Process(); p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "cmd"; p.StartInfo.Arguments = "/?"; p.Start(); Response.Write(p.StandardOutput.ReadToEnd()); p.WaitForExit();
Dig deeper on Win Development Resources
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ...continue reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers.continue reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.