Skip to main content

Test-IsMutexAvailable

SYNOPSISโ€‹

Wait, up to a timeout value, to check if current thread is able to acquire an exclusive lock on a system mutex.

SYNTAXโ€‹

Test-IsMutexAvailable [-MutexName] <String> [[-MutexWaitTimeInMilliseconds] <Int32>] [<CommonParameters>]

DESCRIPTIONโ€‹

A mutex can be used to serialize applications and prevent multiple instances from being opened at the same time. Wait, up to a timeout (default is 1 millisecond), for the mutex to become available for an exclusive lock.

EXAMPLESโ€‹

EXAMPLE 1โ€‹

Test-IsMutexAvailable -MutexName 'Global\_MSIExecute' -MutexWaitTimeInMilliseconds 500

EXAMPLE 2โ€‹

Test-IsMutexAvailable -MutexName 'Global\_MSIExecute' -MutexWaitTimeInMilliseconds (New-TimeSpan -Minutes 5).TotalMilliseconds

EXAMPLE 3โ€‹

Test-IsMutexAvailable -MutexName 'Global\_MSIExecute' -MutexWaitTimeInMilliseconds (New-TimeSpan -Seconds 60).TotalMilliseconds

PARAMETERSโ€‹

-MutexNameโ€‹

The name of the system mutex.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-MutexWaitTimeInMillisecondsโ€‹

{{ Fill MutexWaitTimeInMilliseconds Description }}

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False

CommonParametersโ€‹

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTSโ€‹

Noneโ€‹

You cannot pipe objects to this function.โ€‹

OUTPUTSโ€‹

System.Booleanโ€‹

Returns $true if the current thread acquires an exclusive lock on the named mutex, $false otherwise.โ€‹

NOTESโ€‹

This is an internal script function and should typically not be called directly.

http://msdn.microsoft.com/en-us/library/aa372909(VS.85).asp

https://psappdeploytoolkit.com