How to open and close an application in the server from code

You can use the below code snippet. Kill() method to stop the process and Start method to start the application. But remember it will open the application in the server. Not in the client side.

using System.Diagnostics;

int _processID;

private void button1_Click(object sender, System.EventArgs e) {
Process p = Process.Start("program.exe");
_processID = p.Id;

private void button2_Click(object sender, System.EventArgs e) {
foreach (Process proc in Process.GetProcesses()) {
if (proc.Id == _processID) {

No comments: