Skip to content

Instantly share code, notes, and snippets.

@mobius
Created May 31, 2011 04:28
Show Gist options
  • Save mobius/999861 to your computer and use it in GitHub Desktop.
Save mobius/999861 to your computer and use it in GitHub Desktop.
C# startup a process in hidden mode
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace RunAsHidden
{
class Program
{
static void Main(string[] args)
{
if ( args.Count() > 1 )
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.FileName = args[0];
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
for (int i = 1; i < args.Count(); i++)
{
startInfo.Arguments += @" " + args[i];
}
Process process = Process.Start(startInfo);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment