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