Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to handle locked file from command line and release it? [closed]

Is there a way to detect locked files in specify folder and release them by command line?

Something like this in pseudo-code:

for file in folder do
unlock file
like image 647
David Michaeli Avatar asked May 20 '12 09:05

David Michaeli


People also ask

How do I unlock a file in command prompt?

Unlock the File Using Cmd To unlock a file, type the command given below into the command prompt and press the Enter Key. For example: To unlock the "noida_chapter. txt" file, run the command as, cacls E:\new\c#corner\noida_chapter. txt /P everyone:f, where f represents the user's access right to full control.

How do I release a locked file?

Right-click on the file. In the menu that appears, select Lock File. To unlock, right-click the file and select Unlock File.


1 Answers

Yes, this is possible using a free utility called Handle, by Mark Russinovich.

It can be download here from Microsoft.

This runs from the command line, and will tell you which program has a particular file or directory open, based on whether it has an open handle to that resource.

By running handle.exe with the -c flag, you can also force the specified handle closed, which will unlock the resource. But fair warning: this will likely cause the application using the resource to crash, perhaps even the entire system to become unstable. So I wouldn't make a habit of doing this; only use it for special cases like debugging where you expect some instability.

like image 69
Cody Gray Avatar answered Oct 19 '22 02:10

Cody Gray