Sunday 28 January 2018

filesystems - Find out which process is locking a file or folder in Windows


How can I find out which process is locking a file or folder in Windows?


For instance, when trying to delete a folder, Windows reports this:



The action can't be completed because the folder is open in another program



Happens the same with a file, but how do I find out what program or application is currently using it and preventing me from deleting the file or folder?



Answer



PowerShell method:


IF((Test-Path -Path $FileOrFolderPath) -eq $false) {
Write-Warning "File or directory does not exist."
}
Else {
$LockingProcess = CMD /C "openfiles /query /fo table | find /I ""$FileOrFolderPath"""
Write-Host $LockingProcess
}

The openfiles command needs to have support for local files enabled, by running openfiles /local on and restarting.


More details How to find out which process is locking a file or folder in Windows


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...