Methods to delete files via command line: Normally I take ownership of the folder/files (takeown):
takeown /f c:\folder\location /r /d y
- /r Performs a recursive operation on all files/folders.
- /d Suppresses the confirmation prompt.
- y Yes Take ownership of the directory.
Change Permission (icacls):
icacls c:\folder\location /grant administrators:F /t
- /t Performs a recursive operation on all files/folders.
Delete Process (del):
del c:\folder\location\*.* /s /q
- /q Quiet mode, do not ask if ok to delete on global wildcard
- /s Delete specified files from all sub-directories (DELTREE).
- /f Force deleting of read-only files.
Delete Process (RD):
RD /S /Q c:\folder\location\
- /q Quiet mode, do not ask if OK to delete on global wildcard
- /s Delete specified files from all sub-directories.
Example using RD to remove a troublesome files that just wouldn’t delete: