Test-IsMutexAvailable keeps timing out install

Hello,

Recently I have been running into issues when installing an MSI that the Test-IsMutexAvailable step runs the install will time out after 10 Minutes.

I have rebooted the device and still the issue remains.

Is there anything that I can do to change the Mutex or change it’s state to Available?

Is Windows Installer - msiexec installing something else on the machine?
Seems like Mutex has not been released.

No the msiexec is not installing anything. I have restarted the Windows installer service and restarted the device. I did some more digging and loaded the PSADT AppDeployToolkitMain as a module in powershell on the impacted Device.

I was able to run the Test-IsMutexAvailable ‘Global_MSIExecute’ and got the following output:

S C:\WINDOWS\system32> Test-IsMutexAvailable 'Global\_MSIExecute'                                                      [12-04-2020 08:23:08.237] [Initialization] [Test-IsMutexAvailable] :: Check to see if mutex [Global\_MSIExecute] is available. Wait up to [1 millisecond(s)] for the mutex to become available.
[12-04-2020 08:23:08.362] [Initialization] [Test-IsMutexAvailable] :: Mutex [Global\_MSIExecute] is not available for an exclusive lock because the following MSI installation is in progress [].
False

From that you can see that there isn’t actually anything running.

I also opened the Mutex Thread to see what it was doing. Here is the Output from that:

PS C:\WINDOWS\system32> [Threading.Mutex]$mutex = [Threading.Mutex]::OpenExisting('Global\_MSIExecute')     
PS C:\WINDOWS\system32> $mutex
                                                                                       
Handle SafeWaitHandle
------ --------------
  3512 Microsoft.Win32.SafeHandles.SafeWaitHandle

I’m not sure what that means exactly. I’m not too familiar with .NET calls or what they mean.

After this I was able run these following commands. They didn’t seem to make a difference.

$mutex.Dispose()
$mutex.Close()

This is now happening on multiple application using the PSADT.
Any help would be appreciated.

Here is what I see when there is an msi running for reference.

 PS C:\WINDOWS\system32> Test-IsMutexAvailable 'Global\_MSIExecute'                                                      
[12-04-2020 10:33:50.120] [Initialization] [Test-IsMutexAvailable] :: Check to see if mutex [Global\_MSIExecute] is available. Wait up to [1 millisecond(s)] for the mutex to become available.
[12-04-2020 10:33:50.167] [Initialization] [Test-IsMutexAvailable] :: Mutex [Global\_MSIExecute] is not available for an exclusive lock because the following MSI installation is in progress ["C:\WINDOWS\System32\msiexec.exe" /i "C:\PSADTInstall - Type2\Files\ImprivataAgent_x64.msi"].
False

It needs to be released.

[Threading.Mutex]$mutex = [Threading.Mutex]::OpenExisting('Global\_MSIExecute')
$mutex.ReleaseMutex()

However this looks like a bug since it told you it was locked, but you were able to open it just fine.
Does it do it under SYSTEM too?

Yes, this still happens when running as system. It doesn’t appear to make a difference running as system, as user, or as administrator.

I have tried running command and this is the output I get:

PS C:\WINDOWS\system32> [Threading.Mutex]$mutex = [Threading.Mutex]::OpenExisting('Global\_MSIExecute') 
PS C:\WINDOWS\system32> $mutex.ReleaseMutex() 
Exception calling "ReleaseMutex" with "0" argument(s): "Object synchronization method was called from an
unsynchronized block of code."
At line:1 char:1
+ $mutex.ReleaseMutex()
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ApplicationException

So I’m not able to release it.