Created
May 31, 2011 04:28
-
-
Save mobius/999861 to your computer and use it in GitHub Desktop.
C# startup a process in hidden mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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