如何从文件夹中删除写保护以使用cmd删除它? [英] How do I remove write protection from a folder to delete it using cmd?

查看:164
本文介绍了如何从文件夹中删除写保护以使用cmd删除它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个文件夹,我正试图通过删除写保护来删除它.但是,该方法似乎均无效.这就是我尝试过的.

I have this folder which I am trying to delete by removing the write protection. However none of the method seems to be working. This is what I have tried.

set "dir=C:\\Training\\Client target"
for /F %%i in dir do (
    takeown /F %%i /R /D Y
    cacls %%i /T /C /G *******\<username>:F
    rd /S /Q %%i )
PAUSE

尝试过此C:\Training>RMDIR /S /Q "C:\Training\Client target"

我得到了

C:\Training\Client target\File1 - The media is write protected.
C:\Training\Client target\File2 - The media is write protected.
C:\Training\Client target\File3 - The media is write protected.
C:\Training\Client target\File4 - The media is write protected.
C:\Training\Client target\File5 - The media is write protected.
C:\Training\Client target\File6 - The media is write protected.

推荐答案

该错误媒体已写保护";不是由于ACL,如果这是ACL问题,则会出现访问被拒绝(err = 5)错误.同样不是在文件上设置了readonly属性.这听起来像是将卷本身设置为只读.不知道怎么回事,但是您可以通过运行diskpart来确认:

That error, "The media is write protected" is not because of ACLs, if it was an ACL problem you'd get an Access Denied (err=5) error. It's also not that the readonly attribute is set on the files. This sounds like the volume itself is set to read-only. Not sure how that happened, but you can confirm it by running diskpart:

-运行Diskpart(您需要提升为管理员)

-Run Diskpart (you will need to elevate to admin)

-类型列表磁盘(请注意包含文件的磁盘号,假设它是0)

-Type List Disk (take note of the disk number that contains your files, let's assume it's 0)

-键入选择磁盘0(或任何磁盘号)

-Type Select Disk 0 (or whatever the disk number is)

-类型属性磁盘(请查看只读设置,如果为True,那么这就是您的问题)

-Type attributes disk (look at the read-only setting, if it's True, then this is your problem)

假设只读为true,然后键入:

assuming read-only is true, then type:

将磁盘清除属性归为只读

attributes disk clear readonly

这篇关于如何从文件夹中删除写保护以使用cmd删除它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆