Start a proccess from C# in the background

Posted on 2009-12-26
Last Modified: 2013-12-17
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,
Question by:mkrisz
    LVL 11

    Accepted Solution

    here is what you can do:
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName = "cmd.exe";
                proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                proc.StartInfo.CreateNoWindow = true;
    LVL 11

    Assisted Solution

    Then remember to do proc.kill() when you want to end it, else it will run after you terminate your application.
    LVL 11

    Expert Comment

    here is an even nicer example from (
    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);
       ExitCode = Process.ExitCode;

       return ExitCode;

    LVL 5

    Author Closing Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    This is an explanation of a simple data model to help parse a JSON feed
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now