We can’t delete a readonly file using straight ‘del’ command. We get access denied error in this scenario.
c:\>attrib readonlyfile.txt
A R C:\readonlyfile.txt
c:\>del readonlyfile.txt
c:\readonlyfile.txt
Access is denied.
c:\>
We can use /A switch to delete such files with special attributes set. To delete read-only files we need to add /A:R to the del command.
Example:
c:\>del /A:R readonlyfile.txt
{ 1 comment… read it below or add one }
we can use /F switch too.. "del /F readonlyfile.txt" also works.