Labels

Thứ Tư, 16 tháng 10, 2013

[EN] Windows Tip: Force delete a folder or file in Windows

You need to download the tool psexec first.
Suppose that the folder to force delete is c:\<folder>, First, you will need to take ownership of the folder of file to force delete.  In a cmd Command Prompt running as administrator, enter the following command:
takeown /F C:\<folder>\* /R /A
Next, in the command prompt, type
psexec /s /i cmd
This will start a new cmd Command Prompt running as the System account.  In the new command prompt, enter the following command to grant administrators full rights to all files and to all folders.
cacls C:\<folder>\*.* /T /grant administrators:F
Exit the command prompt running as the System account by typing exit.
Finally, in the initial command prompt running as administrator, type
rmdir /S /Q C:\<folder>\
and hit Enter. This will force delete the folder.
Source: scottge