Created
March 5, 2020 04:16
-
-
Save mryssng/78d24a66591b838bd685eeeb39b3fe27 to your computer and use it in GitHub Desktop.
Start local system process with hide the window.
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
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