通过注册表强制解锁文件占用

将下面的文本保存为 xxx.reg 并运行一下,添加注册表项目。

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT*shell	akeownership]
@="Take ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT*shell	akeownershipcommand]
@="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"
[HKEY_CLASSES_ROOTexefileshell	akeownership]
@="Take ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOTexefileshell	akeownershipcommand]
@="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"
[HKEY_CLASSES_ROOTdllfileshell	akeownership]
@="Take ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOTdllfileshell	akeownershipcommand]
@="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"
[HKEY_CLASSES_ROOTDirectoryshell	akeownership]
@="Take ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOTDirectoryshell	akeownershipcommand]
@="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant administrators:F
/t"

需要删除时只需要右键选择Take Overship

当你要删除一个文件而遇到“无法删除需要权限”的提示时,只要对着文件按下右键,选择『Take ownership』再删除文件即可。

原文地址:https://www.cnblogs.com/csnd/p/11776698.html