Monday, May 28, 2012

Stop running processes

Hi,
Below is the code I had developed in C# for stopping the running processes on a user machine. This will be helpful while installing certain custom applications from installer.

 Process[] myProcesses;
// Returns array containing all instances of Notepad.
myProcesses = Process.GetProcessesByName("Notepad");
foreach(Process myProcess in myProcesses){
    myProcess.CloseMainWindow();