PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

File LockSmith via commandline

Open nutnutwin opened this issue 2 years ago • 15 comments

Description of the new feature / enhancement

Thank you for creating this feature

I went through documents https://learn.microsoft.com/en-us/windows/powertoys/file-locksmith and found no info on how to unlock folder using commandline(CMD)

Scenario when this would be used?

to unlock folder using programming

for example, in LockHunter https://lockhunter.com/

I can run in

C:\Program Files\LockHunter\LockHunter.exe "C:\Temp" to unlock folder

Supporting information

No response

nutnutwin avatar Nov 27 '22 01:11 nutnutwin

It would be also useful for me. I think outputting list of processes which is using current file is more important than killing some of them (taskkill can do that).

jdfa avatar Mar 17 '23 14:03 jdfa

+1 Agreed

pranavpa8788 avatar Mar 21 '23 14:03 pranavpa8788

+1 would be also useful for me

mortl3000 avatar Apr 06 '23 08:04 mortl3000

+1, would also like this feature

xaviercarmo avatar Apr 17 '23 23:04 xaviercarmo

+1

joehom0416 avatar May 17 '23 02:05 joehom0416

+1

simbarras avatar Jun 12 '23 20:06 simbarras

+1 Edit: not needed anymore, I switched to Linux. It was easier. Although I highly support the adding of this kind of power user toys to Windows.

David-Kyrat avatar Sep 07 '23 18:09 David-Kyrat

See my comments in https://github.com/microsoft/PowerToys/issues/28529

lwahonen avatar Sep 25 '23 11:09 lwahonen

+1

PZan avatar Apr 18 '24 12:04 PZan

Need this so badly. Sysinternals handle is a piece of junk and doesn't work.

cow1337killer3 avatar Apr 26 '24 10:04 cow1337killer3

There are already existing console tools

Don't they do what is asked?

PolarGoose avatar Sep 07 '24 12:09 PolarGoose

The version I implemented has features like "wait until target process closes before returning", which is immensely useful in scripts.

lwahonen avatar Sep 07 '24 12:09 lwahonen

@lwahonen,

You can do that with a small PowerShell script:

param (
    [Parameter(Mandatory=$true)]
    [string]$PathToTheFileOrFolder
)

$handleInformation = & "$PSScriptRoot/handle64.exe" -accepteula -nobanner -v $PathToTheFileOrFolder
foreach($lockingProcess in ConvertFrom-CSV -Delimiter "," -InputObject $handleInformation) {
    Write-Host "Kill locking process: $lockingProcess"
    Stop-Process -Id $lockingProcess.Pid -Force

    Write-Host "Wait until the process is stopped"
    while (Get-Process -Id $lockingProcess.Pid -ErrorAction SilentlyContinue) {
        Start-Sleep -Seconds 1
    }
}

Also, Sysinternals Handle is more reliable. When run from an admin, it uses a kernel driver, PROCEXP152.SYS, to get the locking information.

PolarGoose avatar Sep 07 '24 13:09 PolarGoose