windows 删除失去所有者的文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17599765/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:41:22  来源:igfitidea点击:

Delete a folder that lost its owner

windowspermissions

提问by Gimli

I have found myself in a somewhat unique situation.

我发现自己处于某种独特的境地。

I have a folder. This folder, somehow, lost its owner.

我有一个文件夹。不知何故,这个文件夹失去了它的主人。

In "Advanced Security Settings for FOLDER" under "Current owner:" is displayed:

在“文件夹的高级安全设置”中的“当前所有者:”下显示:

Unable to display current owner.

I am trying to delete this folder with no success. I have tried taking ownership with both my user and the Administrator user and both yield

我试图删除此文件夹但没有成功。我曾尝试同时拥有我的用户和管理员用户的所有权,并且都产生了

Unable to set new owner on FOLDER, Access is denied

I have tried to grant administrator full privileges via the Windows shell running as administrator:

我试图通过以管理员身份运行的 Windows shell 授予管理员完全权限:

icacls FOLDER /grant administrators:F

And I have tried to remove the folder via the Windows shell running as administrator:

我尝试通过以管理员身份运行的 Windows shell 删除该文件夹:

rmdir FOLDER /s

which return:

返回:

Access is denied

Does anyone have any idea as to how I can delete this folder?

有没有人知道如何删除这个文件夹?

回答by Gerhard Powell

If you tried to delete a file/folder and it failed due to a process holding on to it, it will lose it ownership. Use Process Explorer and do a search for the folder/file. It will show what process is using that folder/file. When you end the process, the folder/file will disappear.

如果您尝试删除文件/文件夹并且由于进程保留它而失败,它将失去它的所有权。使用 Process Explorer 并搜索文件夹/文件。它将显示正在使用该文件夹/文件的进程。当您结束该过程时,文件夹/文件将消失。

回答by KirkSu

Try chkdsk /Fin cmd with admin privilege!

chkdsk /F以管理员权限在 cmd 中尝试!

Because the folder may contain a file without owner, which is an error in your file system.

因为文件夹可能包含没有所有者的文件,这是您的文件系统中的错误。

If that folder is in your boot disk (C:), cmd will ask you whether to scan when the next time you launch the computer, type "y" to confirm.

如果那个文件夹在你的启动盘(C:)里,下次开机的时候cmd会问你是否要扫描,输入“y”确认。

After the scan chkdskwill delete the damaged file(s).

扫描chkdsk后将删除损坏的文件。

I got this problem after uninstalled Android Studio, I can't delete C:\Program Files\Android\Android Studio. Tried DEL/RD/TAKEOWN/ICACLS... for one hour, none of them works for me. Then I realized, that folder contains some damaged files without owner... Guess it's a bug of Windows or Android Studio...

卸载 Android Studio 后出现此问题,我无法删除C:\Program Files\Android\Android Studio. 试过DEL/ RD/ TAKEOWN/ ICACLS... 一小时,没有一个对我有用。然后我意识到,该文件夹包含一些没有所有者的损坏文件......猜测这是Windows或Android Studio的错误......

This is one of the possibility why some folders or files cannot be deleted even with admin privilege.

这是即使具有管理员权限也无法删除某些文件夹或文件的可能性之一。

Hope this helps the questioner and people who have the same problem!

希望这对提问者和有同样问题的人有所帮助!

回答by birkner

I had this problem when I had a cygwin terminal in the locked directory. After changing directories in the cygwin window, I was able to remove the windows directory.

当我在锁定目录中有一个 cygwin 终端时,我遇到了这个问题。在 cygwin 窗口中更改目录后,我能够删除 windows 目录。

回答by vujke

Download and add Take Ownershipregistry. Then right click on folder and press Take Ownershipand choose your username.

下载并添加Take Ownership注册表。然后右键单击文件夹并按获取所有权并选择您的用户名。

回答by Keith Tyler

The ownership of the folder shouldn't affect its deletability, as long as the parent folder's access rights include write access for the deleting user.

文件夹的所有权不应影响其可删除性,只要父文件夹的访问权限包括删除用户的写访问权限。

A folder doesn't really lose its owner, but its owner may cease to exist. However, the folder still has an owner ID, and for most intents and purposes, that is still valid.

文件夹并没有真正失去其所有者,但其所有者可能不复存在。但是,文件夹仍然具有所有者 ID,并且对于大多数意图和目的,它仍然有效。

@birkner is on the right track. Check to see if you have any processes running in that directory, and if so, terminate them.

@birkner 走在正确的轨道上。检查是否有任何进程在该目录中运行,如果有,则终止它们。