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
Additional Reading...
- Set read-only attribute from command line
- Clear hidden attribute from command line
- Disable file compression from command line
- Set hidden attribute from command prompt
- Set archive attribute from command line
- Get file system information using fsutil fsinfo command
- How to create large dummy file
- Cacls command examples
- Get File size and directory size from command line
- Encrypt files and folders from command line
{ 1 comment… read it below or add one }
we can use /F switch too.. "del /F readonlyfile.txt" also works.