Cannot delete file or folder

Tue, 2007-07-17 11:46 by admin · Forum/category:

After trying the following methods, please click here to let us all know your results.

Reboot

[Method 1] Reboot, then delete.

DEL or RMDIR

[Method 2] Open a command line window (WindowsKey + R, enter: cmd). Move to the folder in question by means of CD commands like CD \ and CD foldername.

Delete the file or folder by using the DEL command to delete files or the RMDIR (remove directory) command to remove directories (folders).

Kill explorer.exe

[Method 3] If this, on its own, is still not enough, then leave the command line window on the desktop, open Task Manager (Ctrl + Shift + Esc), and kill all explorer.exe tasks. Your desktop will go blank, except for the windows already open.

Now try to delete the offending file by means of the DEL command, or folder by means of the RMDIR (remove directory) command, in the command line window, as described above.

After that, in the command line window enter:

explorer

to restart your desktop. If you closed the command line window, you can still restart explorer by opening the Task Manager by holding down the Ctrl and Shift keys and briefly pressing the Esc key. In Task Manager select Applications, New Task and enter: explorer

Log off

[Method 4] If the previous method fails, particularly with multimedia files, log off, then log on again, but do not select the file in Windows Explorer. The safest way is not to open Windows Explorer in the first place.

Then try the previous method again.

Reboot

[Method 5] An even stronger measure would be to reboot, then try the previous methods again. This would work, for example, if a service has the file open.

Delete containing folder

[Method 6] [Thanks to John Barrington:] If you can't delete a problem file, try deleting the folder that contains the problem file. If this doesn't work, try this next item.

If the problem file and its folder, we'll call (A), is within another folder, we'll call (B), try to delete the folder (B) along with any troublesome contents.

Of course, you want to make sure, if you have any other important files or folders within either folder, that they are saved in another location first.

Use RMDIR on containing folder

[Method 7] Begin like the previous method, but try also

rmdir /s foldername

(replace foldernamewith the name of the folder to be deleted). This command should delete a folder with all its subfolders.

If the folder name contains one or more spaces, enclose it in quotes. Example:

rmdir /s "folder name"

Note that the abbreviated command rd can be used in place of rmdir.

Use short name

[Method 8] If the folder name contains strange characters, use a command line window again, but use the DIR /X command to find the short name (for example: PROGRA~1) and use the short name instead. The short name is DOS compatible and has no more than 8 characters for the main name, a period, then no more than 3 characters for the extension.

Retry the previous methods that use a command line window, but use the short name now.

Note: Sometimes an illegal file name can cause Windows Explorer to use nearly 100% of the CPU time.

[Thanks to astk1:] Sometimes the abbreviated name can have a number other than one and can have an extension. If the above does not work, proceed as follows.

  1. Open a command line window (Start, Run, type: cmd, press the return/enter key).
  2. Navigate to the folder using "cd .." and "cd pathname", where pathname is the name of the next subfolder you want to go into.
  3. Type dir /x to see the actual real short name of the subdirectory. Critically: This may include an extension, e.g. "ABDCEF~1.XYZ".
  4. Type "rmdir /s abcdef~1.xyz", replacing the example name abcdef~1.xyz with your actual folder name.

Safe mode

[Method 9] Boot into safe mode and try to delete the file or folder there.

Stop program

[Method 10] If you're trying to delete a program file, like one with the extension .exe, the cause could be that the program is currently running. Stop it, then delete the file.

If the program starts automatically, check the article Autorun causes on how to remove the start command. Do it, reboot, then delete the file.

Rename or move during next boot

[Method 11] If this also doesn't work, there is a way to rename or move a file or folder during the boot process. For this you need to use the registry editor REGEDIT.EXE. See the Registry warning for a general warning.

Create an entry in

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Session Manager\

named PendingFileRenameOperations of type REG_MULTI_SZ. In pre-XP Windows versions you have to use REGEDT32.EXE to create this value type.

The first line of each pair is the current file or folder path and name with \??\ in front of it.

The second line of each pair is the new file or folder path and name with !\??\ in front of it.

Example for one pair which moves the file mfc42.dll from the temp folder to the system32 folder and overwrites any existing file at the destination:

\??\C:\TEMP\mfc42.dll
!\??\C:\WINDOWS\system32\mfc42.dll

You can add as many pairs as you like. The move operation is performed directly after the next reboot. You can also give folder paths, so the folder will be renamed. But both paths have to be local.

There is a Windows API call for this, named MoveFileEx, and somebody in Germany has even written a utility named MoveEx for it. You can download it from http://wwwthep.physik.uni-mainz.de/~frink/nt.html. Use it if you need this function often. A Posix utility from a Windows Resource Kit named mv.exe also does it, just in case you still have the resource kit around.

Use another operating system

[Method 12] Boot into another operating system to delete the file from there. The other operating system can be, for example, another installation of Windows, BartPE, Knoppix, Ubuntu, or any operating system that can read the file system used (NTFS or FAT32).

Connect hard disk to other computer

[Method 13] Remove the hard disk from the computer and connect it to another computer. Delete the files or folders there.

Use unlock utility

[Method 14] If you cannot delete a file or folder because it is in use, you can use one of the mostly free utilities, such as Unlocker.

Shorten names

[Method 15] If the cause is that the path and file name is too long, first try to rename folders in the path with shorter names.

If that doesn't work, you can use the following method, reported 2007-05-17 by Mark Briody:

Open a command line window and use the subst command to create a virtual drive to the folder containing the long file name, e.g. (all in one line):

subst x: "C:\Documents and Settings\briodym\Favorites\Mark\Gadgets and Hardware\Hardware\Stores\eBuyer"

Then change to the virtual drive x:, and you should be able to delete, rename, and move files and folders.

Finally, to clean up, remove the subst again with:

subst x: /d

Deal with hidden or system files

[Method 16] [Thanks to warpcoil, who first described this method in a comment below]

This method deals with files that carry the hidden or system attribute. You can delete such files in Windows Explorer, if you set the folder options such that these files are shown in the first place, but the following method can delete them from a command line window.

Open a command line window and navigate to the offending folder by means of the cd command.

Show all files, using the attrib command. Note the attributes displayed as single letters on the left side of the listing:

Letter  Attribute
R Read-only
H Hidden
S System

Delete the offending files with the commands:

del /f /a:s

del /f /a:h

Replace with the name of the offending file or files. You can use wildcard characters. For example, the following command:

del abc*.* /f /a:h

would delete all files whose names begin with abc and which carry the hidden attribute, regardless of the system or read-only attributes.

When it works you get no response, but typing attrib again will show that the file has gone.

Results

After trying the above methods, please click here to let us all know your results.

Average: 3.6 (178 votes)

Cannot delete folders, access denied

Sun, 2009-01-04 16:42 by MisterEd

I can't delete three folders.

Among the other folders the F:\ Partition has a folder with two subfolders:

4fbbc9a731b8358b44f945be7229ef02
-> amd64
-> i386

There owners are: "S-1-5-21-1606980848-1935655697-839522115-1003"

The properties of "4fbbc9a731b8358b44f945be7229ef02" show:
0 files, 2 folders, 0 bytes

With Windows Explorer I set:
[X] Show hidden files and folders
[ ] Hide protected operating system files

There appears to be nothing hidden
Also, if I try to acccess either "amd64" or "i386" I get "Access is denied"

I have tried to delete these folders using most of the mentioned methods with no luck
These include:
* rmdir and rmdir /s
* logging off and on
* rebooting
* Unlocker delete
* Unlocker delete on next boot
* Safe mode with command prompt
* Shortening the name of "4fbbc9a731b8358b44f945be7229ef02" to "4fbbc9"
* Changing the ownership of all three folders to my account (I am an administrator)

Access rights

Sun, 2009-01-04 22:56 by admin

Two things need to be done:

  1. Take ownership. You have already done that.
  2. Give yourself (or 'Administrators', if you are in that group) all access rights.

You need to do that for any content of the folders as well.

The folders have probably been moved from another computer, hence the strange owner, whose common name is not known on this computer. It would be easier, had they been copied, rather than moved, but it's still possible to give yourself access rights.

By the way, this same problem also occurs when you want to delete the System Volume Information folder (after disabling System Restore for the drive).

Did this work in your case?

I had the same problem, I

Thu, 2008-08-28 08:37 by Jane Fox

I had the same problem, I studied the way of using all these commands for some time and then I bought File / Folder Clean-Up Tool(Long Path) at the address http://www.abtollc.com/products.aspx and cleaned everything i wanted to.

i3WM078's picture

None worked for me, however...

Tue, 2008-07-29 17:58 by i3WM078

I tried everything on the list to no avail. Still getting the same message:

"The process cannot access the file because it is being used by another process."

Anyway, to cut a long story short...

In a CMD window, I ran CHKDSK with /F /X switches.

CHKDSK forced my drive to dismount.

RD /S & the short name of my problem folder and my 3 problem .MP3 files are FINALLY gone.

Interesting!

Tue, 2008-07-29 21:13 by admin

It seems that you have found yet another reason why a file or folder cannot be deleted—a mangled file system.

Has anybody else seen this before? Please reply.

warpcoil's picture

Alternate method 16

Mon, 2008-06-16 20:48 by warpcoil

I had files on two systems that would not delete and caused backups and AV sweeps to fail; one was on the desktop and the other in the hidden directory folder structure c:\documents and settings\user\local settings\temporary internet files\... used for the IE cache.

This method worked for both, after all the above failed.

Open a CMD window and navigate to the folder, using "attrib *.*" to find the names of the hidden folders and files.
Once in the right folder type "del xxx*.* /f /ash" where xxx is the first characters of the file name sufficient to be unique compared with anything in the same folder you want to keep.

If/when it works you get no response but typing "attrib *.*" will show that the file has gone.

Good method!

Tue, 2008-06-17 06:17 by admin

Thanks for this method! The previous ones didn't contain any that deals with hidden or system files. I have added method 16 to the main article above. A few notes:

Instead of attrib *.* you can just use attrib alone.

You have to use both commands, one with /a:s and the other with /a:h, otherwise you will not delete files that have only one of the two attributes.

Methods 11 to 14 should also work on hidden and system files, but yours is simpler and faster.

Please fill at least a little bit of information about yourself in your personal profile (click on Edit, Personal information). We don't even know whether you're a man or a woman. (:-) I will remove this paragraph later. In return you can get your own personal blog here, if you like.

Ubuntu to the rescue

Thu, 2008-05-22 00:39 by Packrat1947

Taking ownership can be done, but it's a complicated process. You could always download and burn a Ubuntu 7.10 bootable disc. You can even buy one for a dollar.

You'll boot into a Windows like enviroment. Go to Places (at the top of the screen), then open up your recalcitrant folder. Now you can delete, move, or do whatever you please with no permissions, or ownership issues.

One time in malware cleaning a customer's machine I had an undeleteable .dll file. This was the ONLY way to remove it. I tried Killbox, MoveOnBoot, and several other methods.

Packrat1947

Unbuntu

Tue, 2008-07-29 16:07 by jputter

I tried with success the Unbuntu 8.04 download. There is a down-loadable 695 MB operating system.It enabled the deletion of folders, which previously could not be removed in the Windows operating system, WinXPPro. These files were not only inaccessible, but prevented a Power Vault RD1000 backup system from working properly. Roxio installed Unbuntu on a CDRW. Then run the Unbuntu program, which offers the option of using the operating system as a demo directly from the CD without an installation or change to the computer settings. Once booted up into the Unbuntu operating system, go to "Places" in the top menu bar and delete any file or folder at will.Other methods to delete inaccessible files such as going into safe mode, truncating the size of folder names in the file pathway, or using remove directory commands in DOS, were not workable solutions.

Good solution

Thu, 2008-05-22 18:55 by admin

Thanks for this solution, which is essentially method 12 above, using a bootable Ubuntu CD. (Ubuntu is a popular Linux distribution.)

Excellent guide

Thu, 2008-05-01 04:11 by Tim 13

I just wanted to take the time out to thank everybody responsible for the creation of this guy. Via torrent sites, I downloaded an album tonight with a cross in the folder name: †

For whatever reason, explorer would shut down whenever I tried to delete these folders or change their names. At a loss for ideas, I showed up to this site, and tried a few of these suggestions. Using the command prompt, I managed to delete the folders that I had emptied out already, but there were even MORE problems after this. At least one of these album folders had folders inside of them which were TOTALLY invisible. Even the command prompt wouldn't find them. So, I used the "delete folder and subfolders," or rd /s, and that ensured that the problem folder was completely empty. From there, I managed to rd the folder itself from my desktop.

It was a war that I could have gone without fighting, but at least now, I'm richer for the experience, and I know how to handle it if I have any similar problems in the future. BAM!

Glad it helped

Thu, 2008-05-01 10:16 by admin

Isn't it strange that the operating system refuses to obey its master's command? Refusing to delete seems to be a particularly nasty transgression, in my personal view. But this web page should transfer the command back to the user. (:-)

"PLEASE FOR THE LOVE OF GOD

Wed, 2008-04-16 17:15 by Pangaea

"PLEASE FOR THE LOVE OF GOD SOMEONE HELP ME, PLEASE PLEASE PLEASE..
IM PREPARED TO PAY FOR THE HELP AT THIS STAGE.. PLEASE PLEASE PLEASE SOMEONE TAKE ME OUT OF THIS NIGHTMARISH HELL THATS BEING GOING ON FOR OVER 2 MONTHS NOW!!!!!! H E L P

2 months ago, i put a new hd into my pc... i slaved the old drive so the old drive is now D: ... by the way im running xp pro sp2.
I reinstalled windows onto the new drive C:
But the old drive D: still has the windows installed onto it.
There are 3 folders on the old drive i want to delete and send to the bottomless pits of hell..

Windows
Program Files
Documents and Settings

Windows REFUSES to delete these folders.. access denied ..etc

I AM logged into an admin account, so i should be able to delete these stupid folders.

I used third party things, like File Unlocker.. with no luck at all

I emailed mircosoft about 10 times regarding this,, either getting no replies, or useless replys... I physically wrote 2 letters to microsoft.. no reply... ive looked at 100`s upon 100`s of forums online, trying 100`s of different methods of deleting these folders... NO LUCK

this is now into the 2nd month of this nightmare. i cant work out how to do this, im angry, in particular with mircosoft, im fed up, and i dont know what to do short of formatting the drive (witch for other reasons is out of the question)

the last thing i tried was this (as directed by someone at mircosoft)
http://support.microsoft.com/kb/308421

sounds simple enough, tho.. if u read it carefully ull soon find out that the information there is not right....
meaning: they state on steps 2 and 3
2: 2. Click the Security tab, and then click OK on the Security message (if one appears).

3: 3. Click Advanced, and then click the Owner tab.

so first of all, step 2, "click OK on the Security message (if one appears)."
i have never never never seen a "security message" doing this in all my countless years using windows
secondly, stop 3, "Click Advanced, and then click the Owner tab." ...
..what the hell are you talking about mircosoft?? click on "advanced".. where the hell are you seeing these options? Owners tab?? are you on the same planet mircosoft?... Are you using some future version of windows as an example here???

PLEASE.. i need some help with this asap.. as im about to litterlaly chuck this pc out the dam window.

POST UPDATE ...... i gave my pc to a guy and payed him 80euro to try delete the folders..... he had no luck at all. tho he did manage to change the ownership of the offending folders to whatever account he was using... he said that after he did that (in safe mode)... he coulnt delete the folder what so ever.... same old story, access denied this, access denied that..

He also tryed taking the slave drive out, and putting it in a caddie, to try delete the folders on 3 different pcs, with 3 different operation systems... 98, 2000, vista ... he is baffled and understands wholly what ive been going thru this past 2 months.

if anyone has a step by step procedure on how to delete these folders or some software that wipes those particular areas of the harddrive please please please please let me know... please , im so begging you, and as i said early ill be prepared to pay some money toward your valued help.

Best Regards
Pangaea

Ps. sorry for the spelling and attitude, but as u now relies, after 2 months of this, im left very very angry and fed up with the whole thing... all i dam well want to do is delete 3 folders on MY OWN pc,.. how dam complicated must this be???"

Pss. The only thing ive managed to do is rename the folders using "unlocker"

Windows = delete me 1
Program Files = delete me 2
Documents and Settings = delete me 3

Delet 3 folders from slave drive

Mon, 2008-09-15 23:01 by Steave_luice

Please my friend use the following way as a last option which must work in any condition.

FORMAT - try this way first.
1) Copy all you important data to master (new) disk from slave (old) by win explorer.
2) Go to my computer, right click your D drive which is old disk, and you will see the option in menu 'format'
click it.
3) copy all your data back from c drive to D now.

please let me know..

What happens when you try?

Thu, 2008-04-17 16:25 by admin

What's the exact error message you get when you try to delete these folders?

These three folders are exactly the ones that cannot be shared on Windows XP with Simple File Sharing enabled, like on XP Home.

My first guess is that you have no access rights to some folder or file in these three folders. The method to get around this is to take ownership of the folder first, then give yourself, or Everybody, full access rights. Then delete them.

Simpler method for deleting long file/folder name

Mon, 2007-12-31 19:39 by ddx (not verified)

I had this problem with long file name, just couldnt delete the folder. The solution is quite simple, you can just 'rename' folders to shorten its/their names and then delete! Just do it in Explorer, shorten each folders name until you can open up last folder, then delete!

Sometimes folder name too long itself

Thu, 2008-02-07 05:25 by astk1

Just thought it might be handy to make it really clear about short and long names. I had a folder with a really really long name (eg "Dorothy and Julie blah, blah, blah and so on and more blah, blah etc" that came about because of Nokia PC Suite syncing, and the folder contained a music file. Windows XP/Explorer wouldn't allow me to do anything with the folder - couldn't open, move, delete, or rename, couldn't delete within command window (cmd.exe) using del doroth~1 as seemed to be suggested in various forums. Here's how:
open command window (start, run, type cmd, press enter)
navigate to folder using "cd.." and "cd pathname" etc
type dir/x to see the actual real short name of the subdirectory AND CRITICALLY this may include an extension eg. "DOROTH~1.STR"
then type "cd doroth~1.str" (that is, whatever your short folder name is)
then delete the files in the directory (say, del *.* or use the short names trick again if necessary)
then cd.. to get back into the parent directory
then "rmdir doroth~1.str" to remove the empty subdirectory/folder

Thanks a lot!

Thu, 2008-02-07 09:29 by admin

Thanks for your good explanation! I have already incorporated it into method 8 above with an attribution to you.

As an early contributor you now also have your own blog on this web site. Please have a look at the "Blogger" forum for details.

Thanks, good hint!

Mon, 2007-12-31 20:46 by admin

Yes, it seems obvious, but sometimes the easiest things are overlooked.

Your hint has been incorporated in the main article, method 15.

The easiest way I found is

Tue, 2008-03-25 14:20 by NoireX

The easiest way I found is to download the programm "Unlocker" which simply deletes every reference to a folder. It also offers the possibility to delete the folder or document at the same time.

Yes, that's method 14

Tue, 2008-03-25 14:52 by admin

I also have Unlocker installed. It is a fine program and makes it easy to delete any recalcitrant stuff.

Recommended for everyone who has this problem more often.

sorry, i posted my post in the wrong area

Wed, 2008-04-16 17:19 by Pangaea

hi, im the guy that posted the farily lengthy post (at the top) regarding the 3 undeletable folders ive been having great trouble dealing with ..

Im not sure why it was posted up there, but its the most recent post in this thread.

I refare to the post subject "PLEASE FOR THE LOVE OF GOD"

New comments at the top

Thu, 2008-04-17 16:21 by admin

When you add a new comment, rather than a reply, it appears at the top. This is intentional, nothing to worry about.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.