Skip to content

Instantly share code, notes, and snippets.

@mryssng
Created March 5, 2020 04:16
Show Gist options
  • Save mryssng/78d24a66591b838bd685eeeb39b3fe27 to your computer and use it in GitHub Desktop.
Save mryssng/78d24a66591b838bd685eeeb39b3fe27 to your computer and use it in GitHub Desktop.
Start local system process with hide the window.
private void button1_Click(object sender, EventArgs e)
{
// Create instance of System.Diagnostics.Process
var proc = new System.Diagnostics.Process();
// Set path to exe file.
proc.StartInfo.FileName = @"[path to exe]";
// Set argument of exe
proc.StartInfo.Arguments = arg;
// Hide window of command prompt
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
// Set to be exited event when the process terminates.
proc.EnableRaisingEvents = true;
proc.Exited += Proc_Exited;
proc.Start();
}
private void Proc_Exited(object sender, EventArgs e)
{
MessageBox.Show("Process terminated.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment