Monday, March 30, 2015

How can I create a process that is running a supplied native executable (e.g., cmd.exe)?

Question:How can I create a process that is running a supplied native executable (e.g., cmd.exe)??

Answer: </P><P align=justify>The following code should run the executable and wait for it to exit before continuing: using System;</P><P align=justify>using System.Diagnostics;</P><P align=justify></P><P align=justify>public class ProcessTest {</P><P align=justify>public static void Main(string[] args) {</P><P align=justify>Process p = Process.Start(args[0]);</P><P align=justify>p.WaitForExit();</P><P align=justify>Console.WriteLine(args[0] + " exited.");</P><P align=justify>}</P><P align=justify>} </P><P align=justify></P><P align=justify>Remember to add a reference to System.Diagnostics.dll when you compile.

Tags:Interview Questions, Microsoft, C#,

Please submit your Interview Answer for the above Question via replying to this post. Thank you for visiting to our blog, Have a Good Day!.



Sponsor Advertisement



Human Resource Management Software

Human Resource Management Software

Powerful, configurable software for human resources management that is easy to manage and remarkably cost-effective, whatever the size of your company. Now there’s a smarter, more efficient way to handle all of your people-related activities. Easy-to-use system manages the full hire-to-retire lifecycle...

No comments:

Post a Comment