Now I find an other solution you can merge with autohotkey or all the script languages, also a batch file, depends on what you need.
You need to use a command line software from Sysinternals, Handle.
First of all you need 3 info of the mutex:
- The name
- The process id, owner of that handle
- The hex code of the handle
If the name of the handle is for sure unique you can skip the process id
https://technet.microsoft.com/en-us/sys ... andle.aspx
Using Handle:
Handle original istruction from Sysinternal
- handle.exe -p 2080 -a _circledock_
Search for an handle called "_circledock_" where the owner is the process 2080, -a is used to show all types of handles, mutex type is not in normal view
- handle.exe -a _circledock_
Search for an handle called "_circledock_" in all the processes, -a is used to show all types of handles, mutex type is not in normal view
You will have a list like this:
Handle output
*More pid if you search with only the mutex name or more result with the same pid if the name is a fragment of the entire name Now you need to get the standard output and isolate the handle hex code, the one between "type: Mutant" and :"\Sessions\1\BaseNamedObjects\_CircleDock_", path of the handle. If you have not used the pid you need to isolate also it.
Last operation, kill the mutex:
handle.exe -p 8308 -c 2C8 -y
-p pid
-c hex handle id
-y Don't prompt for close handle confirmation.
Here is my code "no pid version", I no need of a better code so is simple, written fast to do what I want, no more so the getHandle not work with both with and without pid and the can close handle when the result is only one, theoretically the regex can works only on the first row so can works

Code: Select all
closehandle("_circleDock_")
closehandle(name){
pid := 0
handle := getHandle(pid,name)
if (handle = "") {
return ; handle not found
}
command := "C:\Users\Astryd\Risorse\_CircleDocks\handle.exe -p " . pid . " -c " . handle . " -y"
Run, %comspec% /c %command%,, Hide
}
}
getHandle(ByRef pid,name) {
command := "C:\Users\Astryd\Risorse\_CircleDocks\handle.exe -a " . name
stdout := runStdout(command)
needle := "No matching" ;when Handle found nothing return in standard output "No matching handles found."
IfInString, stdout, %needle%
{
return ""
}
handle := RegExReplace(stdout, "s).*(...): \\Sessions\\1\\BaseNamedObjects\\_CircleDock_.*", "$1")
pid := RegExReplace(stdout, "s).*pid: (\d*).*", "$1")
Return handle
}
; Run a command and return standard output
runStdout(command) {
shell := comobjcreate("wscript.shell")
exec := (shell.exec(comspec " /c " command))
stdout := exec.stdout.readall()
Return stdout
}