Process Termination in C#

20 Feb

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: ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: