How can I terminate a process before installing a program?

I'm working on a system tray application that will likely see frequent future updates. To that end, it would be desirable for our users to have the installer find and kill the application process before trying to install it.

This is the class that I have found for the custom actions of both starting the process after the install, and terminating it prior install.

public InstallerActions( ) : base( ) { System.Diagnostics.Debugger.Launch( ); this.BeforeInstall += ( S, E ) => { System.Diagnostics.Debugger.Break( ); /*IPC Process Termination Method Goes Here*/ }; this.Committed += ( S, E ) => { System.Diagnostics.Debugger.Break( ); try { Directory.SetCurrentDirectory( Path.GetDirectoryName( Assembly.GetExecutingAssembly( ).Location ) ); Process.Start( Path.GetDirectoryName( Assembly.GetExecutingAssembly( ).Location ) + @"\Program.exe" ); } catch { return; } //Return on failure. }; }

It does not work.

I know that there are the Install, Commit, Rollback and Uninstall custom actions, and before when I've tried them I've had no success with them either. This class is contained within the main assembly of the application which has been added to the Custom Actions section of my Setup and Deployment project... but that's all that I've done. Is there something further that I need to do to make these actions get called? I've even attached the VS debugger to the installer, but I see that the class isn't even being called (or, at least, the break points aren't becoming active in the class code which to me says it's not being loaded).

How can I make this work?

EDIT 1 :

For Clarity, it was requested the type of the Setup Project. This is a VS 2013 Setup and Deployment project type:

<img src="https://i.stack.imgur.com/LGT47.png" alt="enter image description here">

See the highlighted project type.

Sorry for not being clear on that.

EDIT 2 :

It has been to me suggested that IPC > Process.Kill( ), so I will explore that method; however, the main problem remains : If Process.Kill( ) isn't being called, whatever other method that needs to be called would not be called either.

EDIT 3 :

According to this link I found, it seems that the custom actions WOULD be getting called - but at a stage far too late to do me any good. I did neglect to mention that I've been running this test with another instance of the program in question running in the background, and have been getting the notification that the install can't continue because of that running program. This, therefore, helps me to understand the reason the actions are failing is because they are never even gotten to; the installer can't terminate the program because the program stops the installer from progressing to the command to terminate the program because Catch 22.

So the question is still valid, but now I have to ask - is it even possible, like say, when the program installer is first being run, to terminate the process, or is it just something the user will have to do manually?


Given what I now know, I am forced to switch from the VS Setup Project to WIX... I don't even know what WIX is beyond some other setup... tool... thing. Stay tuned for future developments...


Killing a process is not a good idea. The process might be in progress of saving some data to a file which could get interrupted. Also, please be aware that there might be other processes with the same name that you're killing - it needn't be yours. This may cause serious data loss.

Try inter-process communication instead, e.g. a named pipe, a certain file in a known directory etc.

In .NET, you might want to try the IpcChannel class.


  • passing parameter to server in ExtJs
  • twisted.internet.error.ConnectError when run scrapy spider
  • Extjs, handling success or failure when doing a standard submit in a form
  • Gforce min not supported for character in data.table
  • How to implement simple validation in Scala
  • calling a fragment from fragment
  • Entity Framework ObjectContext: Concurrency
  • How to get links to open in the native browser in iOS Meteor apps?
  • aapt.exe'' finished with non-zero exit value 1
  • OSX - always hide certain files
  • Compiling dlib on OS X
  • Memory error in python- how to use more memory
  • Differences in dis-assembled C code of GCC and Borland?
  • How to generate and display a QR Code in ionic 2
  • Tamper-proof configuration files in .NET?
  • Code in Job's Script Block after Start-Process Does not Execute
  • Converting a WriteableBitmap image ToArray in UWP
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Algorithm for a smudge tool?
  • Why value captured by reference in lambda is broken? [duplicate]
  • script to move all files from one location to another location
  • javascript inside java/jsp code
  • ILMerge & Keep Assembly Name
  • Running a C# exe file
  • Symfony2: How to get request parameter
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Comma separated Values
  • Java static initializers and reflection
  • Change div Background jquery
  • Bitwise OR returns boolean when one of operands is nil
  • Is there any way to bind data to data.frame by some index?
  • Checking variable from a different class in C#
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?
  • How to load view controller without button in storyboard?