6.10.10

Run C# Console Application Without a Window

Or simply run a hidden Console Application. (C#)

Ok first of all if you want the application to be hidden right click the Project in the Solution Explorer then Properties inside Properties go to Application then Output type and change Console Application to Windows Application.

Now if you want to run a hidden Console Application from a running Console Application we gonna do some coding :)

First of all - using System.Diagnostics;

Then:

Process myProcess = new Process();
myProcess.StartInfo.FileName = @"C:\App.exe"; // Path to the Application
myProcess.StartInfo.CreateNoWindow = true; // YES create in new window
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //Make the new window Hidden :)
myProcess.Start();
Now you'r done :)

Happy coding, and don't forget to subscribe ! :P

3 comments:

  1. Very intersting, I couldn't delete the new process ("The action isn't valid for this thread")

    ReplyDelete
  2. Anonymous1/12/11 14:44

    You can also create a Window Application and simply don't create any windows. If you're looking into creating a background process to run constantly and perhaps provide an API for some actions, you might be interested in services instead.

    ReplyDelete
  3. Yes :)
    I actually ran that proccess from a service so it's all stay hidden :)

    ReplyDelete