windows 有没有办法从命令行处理锁定的文件并释放它?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10672166/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a way to handle locked file from command line and release it?
提问by David Michaeli
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
回答by Cody Gray
Yes, this is possible using a free utility called Handle, by Mark Russinovich.
是的,这可以使用Mark Russinovich 编写的名为Handle的免费实用程序来实现。
It can be download here from Microsoft.
它可以从 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 handleto 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.
通过handle.exe
使用-c
标志运行,您还可以强制关闭指定的句柄,这将解锁资源。但公平警告:这可能会导致使用该资源的应用程序崩溃,甚至整个系统变得不稳定。所以我不会养成这样做的习惯;仅将它用于特殊情况,例如在您预计会出现一些不稳定的情况下进行调试。