Saturday, April 12, 2014

delete folder

You don't need to reinstall windows or anything super complicated like that.

Here's what you need to do. (Note that this also works for the filename too long to delete problem)
Using the following commands in an elevated command prompt, make a new empty directory and use it to overwrite the file you want to delete than delete both directories. Not sure if this would work with a file, probably would if you just made a blank file in a text editor and then changed the file extension to match what you're deleting.

open a cmd prompt as admin (windows+x in win 8 and pick command prompt (Admin) or in other versions hit the windows button and search cmd then right click cmd and click run as administrator. then type these commands. (For example purposes we'll say I'm trying to delete a folder named undeletable in my user folder, just replace C:\Users\JJ\Undeletable with the folder you want to delete, if there are spaces in the directory put the directory in quotes, i.e. "C:\Program Files\undeletable Program" )

mkdir c:\emptyDir
robocopy c:\emptyDir C:\Users\JJ\Undeletable /s /mir
rmdir C:\Users\JJ\Undeletable /S /Q

repeat the process for any other folders or files you need to delete then delete the empty directory with this
rmdir C:\emptyDir

And ta da it works like magic :)

If for some reason it doesn't work try it in the recovery console. For windows 7 and below this requires a windows install disk or recovery disk. You can make a recovery disk in windows 7, can't remember how off the the of my head. boot into the install disk and click repair your computer and cancel any automatic repairs that pop up. Then select command prompt. In windows 8.1 (probably 8 too) you can sign out, then at the login screen click the power button then hold shift and click restart. A recovery option screen should show up, click trouble shoot → advanced settings → command prompt. It will now restart to the command prompt. Then before running the commands run this

diskpart (a dos program called diskpart will open)
list volumes
(Take note of the path that the recovery console sees windows at. If your c drive doesn't have a volume label/name hopefully you at least know what size it is and go off that)
Once you've figured out the correct drive letter paths type...
exit and hit enter

now run the robocopy commands with the adjusted drive letters and all should be well with the world.

That should do it one way or another.

    No comments:

    Post a Comment