PowerToys
PowerToys copied to clipboard
File LockSmith via commandline
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
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).
+1 Agreed
+1 would be also useful for me
+1, would also like this feature
+1
+1
+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.
See my comments in https://github.com/microsoft/PowerToys/issues/28529
+1
Need this so badly. Sysinternals handle is a piece of junk and doesn't work.
There are already existing console tools
- Sysinternals Handle. Note: it doesn't support Unicode file names. Take a fixed version from here
- Handle2
Don't they do what is asked?
The version I implemented has features like "wait until target process closes before returning", which is immensely useful in scripts.
@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.