windows 即使以管理员身份登录也无法删除文件

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

Cannot delete a file even when logged in as an Administrator

windowspowershellcommand-linermdir

提问by user2061853

Please could some tell me what I am doing wrong. I am trying to delete hidden folder through command line. I am running the command line as administrator but still getting message insufficient access.

请有人告诉我我做错了什么。我正在尝试通过命令行删除隐藏文件夹。我以管理员身份运行命令行,但仍然收到访问权限不足的消息。

Here is screenshot of my command line :

这是我的命令行的屏幕截图:

enter image description here

在此处输入图片说明

Here is the code i am trying

这是我正在尝试的代码

rmdir "c:\xampp\htdocs\prestashop\dfs"

I am getting errors like:

我收到如下错误:

Cannot remove item .... You do not have sufficient access rights to perform this operation.

回答by Matt

Just because you are an admin doesn't automatically mean you have rights. Are you running PowerShell as an elevated user (UAC)? Have you checked the permissions of the files in question just to be sure? Are the files in use perhaps? Although if that was the case I would expect access is denied.

仅仅因为您是管理员并不自动意味着您拥有权利。您是否以提升的用户 (UAC) 身份运行 PowerShell?您是否检查了相关文件的权限以确保?文件是否正在使用中?虽然如果是这种情况,我希望访问被拒绝。

Have you tried also using -recurseand -forceto be sure it gets them all? For what its worth rmdiris an alias for Remove-Item

您是否也尝试过使用-recurse-force确保它可以全部使用?因为它的价值rmdir是一个别名Remove-Item

Remove-Item "c:\xampp\htdocs\prestashop\dfs" -Recurse -Force

You will see, from TechNet, that -Force

你会看到,从 TechNet-Force

Allows the cmdlet to remove items that cannot otherwise be changed, such as hiddenor read-onlyfiles

允许 cmdlet 删除不能以其他方式更改的项目,例如隐藏只读文件