Link to home
Start Free TrialLog in
Avatar of mkrisz
mkrisz

asked on

Start a proccess from C# in the background

Dear Eperts,

I would like to start an external command line application from csharp. I have already found a code to do that, but when I run it, it runs the "external" cmd proccess in front of me (like when I start it from cmd.exe). I would like to ask you to show me a code which I can use for running this application with it's arguments, but in the background. So I don't want to see any command line interface popping up. Please, if you have any suggestions to do that, post it to me.

Thank you really much,
Chris
ASKER CERTIFIED SOLUTION
Avatar of lenordiste
lenordiste
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
here is an even nicer example from (http://www.developer.com/net/csharp/article.php/3707996/NET-Tip-Execute-Commands-From-C.htm):
public static int ExecuteCommand(string Command, int Timeout)
{
   int ExitCode;
   ProcessStartInfo ProcessInfo;
   Process Process;

   ProcessInfo = new ProcessStartInfo("cmd.exe", "/C " + Command);
   ProcessInfo.CreateNoWindow = true;
   ProcessInfo.UseShellExecute = false;
   Process = Process.Start(ProcessInfo);
   Process.WaitForExit(Timeout);
   ExitCode = Process.ExitCode;
   Process.Close();

   return ExitCode;
}

Avatar of mkrisz
mkrisz

ASKER

Lenordiste, you forgot the arguments, but I did that, so no problem :) Great solution, thanks.