Category Archives: Code

Process Termination in C#

Just a write-up on a small application, so that I don’t forget what I did.

Problem:  An application keeps spawning multiple instances of msiexec.exe on a Windows 7 desktop computer. Typically, a user would have to go into the Task Manager and manually kill the msiexec.exe process to perform another install. This solution was to create an executable that I could just drop on my taskbar and start up whenever I needed to just kill the msiexec.exe proccess.

Solution: Created a simple C# console application to retrieve all the current running processes on a single windows 7 computer and kill any process named ‘msiexec’.

Example C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ProcessGathering
    class Program
        static void Main(string[] args)
            Process[] myProcesses = Process.GetProcesses();
            foreach (Process myProcess in myProcesses)
                if (myProcess.ProcessName.Equals(“msiexec”))
                    Console.WriteLine(“msiexec.exe found and killed”);
            Console.WriteLine(“Press any key to continue…”);
example code that assisted with this solution:
Leave a comment

Posted by on February 20, 2013 in C#, Code


Tags: ,