tags:

views:

50

answers:

1

Hello to all! Is there a way to determine if there is an active installation running in C#? For example, some times if you launch 2 MSIs (or setup.exes) at once one of them will say that there is already installation going on in progress. Is there a way to do that in C#? Say, a self-resetting registry key (that system resets) or a mutex?

+1  A: 

A mutex is the way to go.

bool isFirst;
Mutex m = new Mutex(false, "MyMutex", out isFirst);

If isFirst is false then there is another process running. As for the name if you want this to check across multiple sessions (terminal sessions) then change the code to something like.

Mutex m = new Mutex(false, "Global\\MyMutex", out isFirst);
Ben Vaughan
right, but what if I want to also see if windows installer is running?
Crypton