Deleting a read only file using batch file or command

batch-file, cmd, delete-file, windows

Solution

Specify `/F`, it will force deletion of read-only files. Also see

del /?

However, that will not work when the file is in use.

Problem

I would like to know a way of deleting a read only file using a batch file or a command. Suppose I have a DLL file named "abc.dll", and I am trying to delete this file using the following command in a batch file: ``` del "C:\test\abcd.dll" ``` It does not allow me to do that and it throws access denied message. However if I change the read only attribute to non read only I am able to successfully delete it.

Original source