Skip to content

Instantly share code, notes, and snippets.

@mxpv
Last active December 14, 2015 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxpv/5090704 to your computer and use it in GitHub Desktop.
Save mxpv/5090704 to your computer and use it in GitHub Desktop.
Unable to delete file or Directory in Windows 7 or Vista
SET DIRECTORY_NAME="C:\Users\MAKSYM~1.PAV\AppData\Local\Temp"
TAKEOWN /f %DIRECTORY_NAME% /r /d y
ICACLS %DIRECTORY_NAME% /grant administrators:F /t
PAUSE
If you do a reinstall of Windows 7 or Vista sometimes you may get files and folders that you cannot delete. I have also had directories on an external drive that I can’t delete when installing an application from that drive.
You will get an error message that access is denied.
This is usually because the file is locked with access control for an account that no longer exists.
You will need to change the directory path to match your requirements e.g. “C:\Locked Directory” to “C:\Delete Me”.
Right click on the file “delete.bat” select “Run As Administrator” and you should now have full control of the directory and all sub directories meaning you can do what you wish with them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment