Check for windows installer mutex

In one of my integration tests, I have two threads that uninstall and then install the program, but when they start, they generate an error Failed to grab execution mutex. System error 258.

To get around this, I have to sleep after removal. I tried to check if the msiexec process was working, but it was 2-3 in sequence, so it was not a good indicator. Is there any way to check if msiexec runtime mutex exists?

+3
source share
1 answer
    bool msiIsRunning = false;
    try
    {
        using(var mutex = Mutex.OpenExisting(@"Global\_MSIExecute"))
        {
            msiIsRunning = true;
        }
    }
    catch (Exception)
    {
       // Mutex not found; MSI isn't running
    }
+5
source

All Articles