HOW TO: Delete an Undeletable or Locked File

June 4, 2007 by Kiltak |

Have you ever run into a situation where you wanted to delete a file, but Windows simply wouldn’t allow you to do it? Personally, these things happen to me all the time, especially when I’m at a client’s house trying to get their machine clean of malware. Have you ever tried deleting a locked file using common windows commands? If so, then you’ll know that this is just not possible.

The main reason behind this is that the explorer.exe process locks files that are in use, effectively preventing you from deleting them. Usually, these files should not be touched, but sometimes, situations arise when you really need to erase some troublesome ones.

Fortunately, there are a few easy solutions to delete those files.

Solution #1: Kill explorer.exe

  • Open a command prompt
  • Navigate to the location where the locked file is
  • Press CTRL-ALT-DEL, click on “task manager”, select the Processes tab
  • Kill the explorer.exe process via the “End Process” button
  • Go back to the command prompt and delete the file
  • Bring up the task manager windows again
  • Select file->new task
  • Type explorer.exe in the “create new task” field
  • Press OK.

Solution #2: Use The Windows Recovery Console

Just stick your Windows CD in your CD tray, boot on it, and at the “Welcome to Setup” screen, press “R“. Once the recovery console has started, navigate to the location of your locked file, and delete it. Since WRC does not really start the system, the files will not be in use, and you will be able to delete them

Solution #3: Use unlocker

Unlocker is a very useful freeware that will allow you to unlock any files that are currently in use by Windows. You’ll know if this is happening if you are getting any of these messages when trying to delete a file:

  • Cannot delete file: Access is denied
  • There has been a sharing violation
  • The source or destination file may be in use
  • The file is in use by another program or user
  • Make sure the disk is not full or write-protected and that the file is not currently in use

Unlocker will make things right again for you.

You’ll notice that right after installing the software, a new option named “unlocker” will appear when right clicking any files or folders in Windows Explorer. To unlock a locked file, just right click it, select unlocker, and the unlocker software will start. Then, click “unlock all” and close the software. Now that your file is unlocked, just delete it in Windows Explorer, as you always do. This is much simpler than solution #1 or #2, isn’t it?

I hope these three solutions will help you get rid of those hard to delete files. If you’ve got any additional suggestions, the comment section is open for your comments!

You Might Also Like:

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • bodytext
  • StumbleUpon
  • Fark
  • Reddit
  • Technorati
  • Mixx
  • Pownce
  • Slashdot
  • TwitThis

Did you enjoy this post? If so, subscribe to the geeksaresexy RSS feed.

RSS feed | Trackback URI

76 Comments »

Comment by Mackenzie
2007-06-04 11:06:48
4. Boot with a live cd, and mount the drive. cd to the drive (probably /media/disk) and then to the folder where the file is. sudo rm
Comment by Kiltak
2007-06-04 11:10:00
Yeah, I was thinking about adding this to the list too, any Linux Live CD will do the trick nicely :)
Comment by Mackenzie
2007-06-04 14:30:23
there needs to be preview on here

that should have said “sudo rm <filename>”

Now let’s hope that worked.

(Comments wont nest below this level)
 
 
 
Comment by peter
2007-06-04 11:09:06
Now that is a program I really need and can use- Thanks
 
Comment by The Thinking Blog
2007-06-04 12:48:27
Unlocker is a really useful program.. I’ve been using it for some time now.
 
Comment by Bucky
2007-06-04 14:27:11
I’ve been using unlocker for a couple of years now. It is always one of the first programs I install when I do a new installation.
 
Comment by grimman
2007-06-04 21:05:25
The easiest way though, which requires no tools at all, is to simply rename the file and reboot. I’m not sure whether Explorer allows you to rename files that are in use, but Total Commander does, and without whining too, and I would guess the command prompt would be equally accomodating.
Comment by Bucky
2007-06-05 16:59:48
If you reboot, the file will unlock whether you use any tools or not. ;)

I think the purpose is to save having to reboot. :)

Comment by Josh
2007-06-06 13:21:56
That’s not necessarily true. Sometimes programs that run at startup or malicious software may be using the file even after a reboot.
(Comments wont nest below this level)
Comment by Kiltak
2007-06-06 16:05:20
Yeah, exactly.. I was about to tell that to bucky.

Even if you boot in safe mode or select “command prompt only”.. the file will be locked.. that’s when these techniques come in handy.

 
 
 
 
Comment by Bryan Price
2007-06-05 07:40:19
I use something called dellater. It’s a command line program, but it gives you a Windows dialog box to confirm the deletion. It will require a reboot to actually do the deed, but there’s no installation, and no fiddling with CDs either.
 
Comment by Devin
2007-06-05 09:05:13
Hmm.. I like that unlocker program. Good to know.
 
Comment by someonesomewhere
2007-06-06 13:17:52
Download Process Explorer from sysinternals Press Ctrl+F and search for the filename which is locked. Once found, close the handle of that file.

Now you can delete it.

 
Comment by Zachary Kent
2007-06-06 14:03:00
Unlocker rocks! It also works great when Windows won’t let you unplug a USB device. I had a USB hard disk that would never release. I ran Unlocker and noticed that mim.exe was locking it. mim.exe is part of Musicmatch which I don’t use.
 
Comment by BAM
2007-06-06 16:31:57
Unlocker is great. But I still want to find a way around the problem of not being able to safely remove USB devices. No file handles open on the device, yet Windows still says something is using it.
 
Pingback by mandmspace.com
2007-06-06 22:10:26
[...] Today November 2006 … Subscribe to Physics Today Email alert RSS feed REGISTER| SIGN IN | SUBSCRIBE | SITE FAQ HIGHLIGHTS - November 2006 [...]
 
2007-06-06 23:02:45
[...] Windows’un silmeye izin vermedii dosyalar silmenin yollar: [...]
 
Comment by estonian
2007-06-07 01:44:23
just delete it from commandline.
Comment by Kiltak
2007-06-07 02:28:12
I don’t think you ever really tried to delete a locked file, else you wouldn’t have left that comment..
Comment by Sturmey
2008-02-09 05:45:40
obviously you’ve never used the command line.

permissions are different in cmd. rename the file. then delete the renamed file. works about 80% of the time. after that you can go to the more labour intensive solutions.

But why mess with all that for the easy ones?

(Comments wont nest below this level)
 
 
 
Comment by monographix
2007-06-07 03:23:10
Solution #4: Share the folder where your file is located in a LAN shared with Macs and have a Mac delete the file :P
 
Comment by jfatz
2007-06-07 04:47:42
The REAL bitch comes from NTFS streams… You can’t even easily delete the buggers when booting off a loader disk.

If anyone has a quick and dirty cure for those damn things, I’ll bake you a pie!

Comment by Juan Subscribed to comments via email
2008-03-03 07:43:35
jfatz. Just boot off a linux LiveCD (any distro will do) and delete the bugger’s.
 
 
Comment by jackhab
2007-06-07 05:51:03
There is much more elegant way to deal with the problem. Locked file means some process uses it. Get Sysinternals Process Explorer from . This great utility (which is a free and better replacement for Windows Task Manager) has a find file handle tool which will show you the process locking the file. Then you can decide what to do: gracefully close the process, kill it or may be leave the file locked.
BTW even if the file is locked by Windows Explorer you don’t have to restart - simply kill Explorer in the Task Manager and run it again.
 
Comment by Tobbi
2007-06-07 06:08:21
I often use Unlocker. It’s really a great tool and it works very often.

Greets

 
2007-06-07 07:51:08
[...] Unlocker 是一个我使用很长时间的软件。由于 Windows 本身的机制,当程序打开一个文件时,有时它会利用文件锁锁住这个文件以防其它程序或操作对其修改。Unlocker 就是一款可以开锁的软件,当你删除那些“在使用”的文件时,Unlocker 就会自动弹出来提示您是否解除锁定并删除,非常方便。 [...]
 
 
2007-06-07 16:42:44
[...] How to Delete an Undeletable File | [Geeks Are Sexy] Technology News Solution #3: Use unlocker Unlocker is a very useful freeware that will allow you to unlock any files that are currently in use by Windows. You’ll know if this is happening if you are getting any of these messages when trying to delete a file: (tags: windows delete tools tips howto utilities files) [...]
 
Comment by zkam
2007-06-07 17:29:07
I use Unlocker and Process Explorer, as mentioned above… Also look for a program called OpenedFilesView. It also shows open file handles, which you can select and close, or kill the process that has it open.
 
2007-06-07 20:26:19
[...] How to Delete an Undeletable File | [Geeks Are Sexy] Technology News (tags: apps computers download file files free hacks helpdesk windows delete tools tips utilities howto microsoft) [...]
 
Comment by Troy
2007-06-08 00:12:28
wow! I CAN’T believe no one mentioned CACLS.
if there is a file you cannot delete
open the command prompt go to the folder that it is in,
type

cacls /t /p everyone:n

then hit enter it will tell you it processed the file then reboot the computer and you will be able to delete it.

you can cacls as many files as you want before the reboot.

all this does is lockdown the file so that it cant start after reboot.

 
2007-06-08 13:29:14
[...] and it says “NO, SOME PROGRAM IS USING THAT. IT’S LOCKED. FECK OFF!”. Ha. Well, thanks to Unlocker, you can TAKE THE POWER BACK. Oh [...]
 
Comment by adrian
2007-06-09 01:37:54
hmm, nice thing i didn`t know that!
 
2007-06-10 05:51:13
[...] Vía Geeks Are Sexy Prohibida su copia total con o sin fines comerciales. Copias parciales deben citar la fuente. [...]
 
2007-06-10 07:00:35
[...] Veröffentlicht 10. Juni 2007 Bookmarks How to Delete an Undeletable File | [Geeks Are Sexy] Have you ever run into a situation where you wanted to delete a file, but Windows simply wouldn’t [...]
 
2007-06-10 12:27:19
[...] Delete a Locked File in Windows I’ve wanted/tried to do this on numerous occasions. The Geeks Are Sexy blog tells you how. [...]
 
Comment by Gotsa
2007-06-10 14:38:57

Non command line file deletion w/o using explorer:

Open taskmanager>kill explorer>run: iexplore \>browse for file and delete it>run explorer

 
2007-06-22 13:26:11
[...] How to Delete an Undeletable File [...]
 
Comment by SHASHANK JOSHI
2007-06-27 02:10:39
thanks people it really helped a lot a file was bugging me to death and yur comments helped to do it via that software unlocker 1.85
really thnx!
 
Comment by Mr. Anderson
2007-07-17 12:54:05
Would this method work for copying uncopyable files? I tried it but to no success but it seems the method should work.
 
Comment by Filefree
2007-07-19 04:43:24
Nahh… proabably in a network, file might be read only… or on running process.
 
Comment by Kingdell2000
2007-08-27 15:49:33
Well how about this. Trying to defrag a disk and the operation stops with the statement “Defrag stopped because of a bad file c:\System Volume Information\_restore{94887…).exe”. Going to Cmd Prompt and bring up the directory c:\SVY there are no files in the folder. The directory only shows the two system entries with no volume. What kind of an answer is there to that situation?
 
Comment by Joebobthedole
2007-08-31 08:18:00
Hi,

I have a very tricky piece of spyware that attached itslef to explorer.exe and winlogon.exe
It’s not a problem to unlock it from explorer, but if winlogon.exe is killed, the computer shuts down immediately. I tried using unlocker, but like I said, the computer just shuts down immediately.

Any other suggestions?

Comment by Kiltak
2007-08-31 09:00:35
Yeah, just use the Recovery console within the XP / 2000 boot CD… navigate to the location where the file is, and delete it..
 
Comment by noname Subscribed to comments via email
2008-03-03 07:59:40
joebobthedole. To fix your problem do this. First back everything up to USB stick or DVD’s, then get a kubuntu liveCD and boot off it, use the “install” icon in the GUI you’re presented with and run through the wizard that appears, then finally reboot and the spyware is gone for good.
 
 
Comment by ed
2007-09-06 17:40:59
Ok, I have an undelable file on my desktop. I have ran unlocker, MoveOnBoot and command prompt. Still can’t get rid of this file. It is a gif file
Any help????
 
Comment by Ordyner
2007-09-07 21:01:23
sometimes when decompresing a large file made out of several winrar files… winrar freezes and your only option is to end the winrar process by bringing the task manager. the problem is that sometimes that leaves a big 800 meg file that is corrupted and windows doesn’t let you delete. My solution is to create a text document on your desktop, then rename the new text document exactly as the corrupted file
and then drag this new file and overwrite the corrupted file. this solution also works sometimes with files that windows won’t let you delete or move from one folder to another.
 
Comment by Joff Subscribed to comments via email
2007-09-26 12:18:40
YOU ABSOLUTE STAR!!!!! Ordyner, you are a genius!

I had two files on my server (w2k3) which, if I tried to do ANYTHING with (right click, hover over, delete, view properties - even del through cmd) it would BSOD! I’d tried serveral repair tools to no avail.

Who would have thought that just copying a non-corrupt file over the top would work!!! It did though, and thank you soooo much :)

Joff
(sorry for using so many exclaimation marks btw)

 
Comment by TNT-ROX
2007-12-06 04:46:31
Try CACLS from the dos prompt.
Be careful thou, It changes the access rights to the file.
Try:
c:\cacls “” /e /g :F
is fully qualified path. e.g “c:\windows\afile.sys”
is you windows username.

To Reset the permisions try:

These are all the switches for the CACLS command

/t Think of the ‘t’ as meaning trash the original security permissions.

/e Think of the ‘e’ as CACLS inviting you to edit. Alternatively think of ‘e’ for append or correct one that went wrong.

/g This is the main switch, ‘g’ means grant; as in: grant me the permissions. This switch requires a user, followed by a colon and letter for the permission. Here are two examples:
/g guyt:f full control for guyt.
/g freddy:r read only for freddy.

/p Almost the same as /g. CACLS /p replaces where as /g appends.

/r Revokes, removes a named user from the Access Control List. Classic usage would be /r users.

/d ‘d’ stands for deny. Remember that if deny the users group the result is that nobody is able to see the files, so use /d sparingly.

/c ‘c’ is for continue. This switch works for CACLS like, ‘on error resume next’ works in VBScript. Adding /c says to CACLS, ‘Carry on despite an error’.

Be careful !!

 
Comment by WTF
2007-12-08 23:49:26
What’s with all the non-English posts?

Maybe someone can explain this to me. The article is written in English; therefore, it follows that posting a (relevant) response to it shows that you know English. If you know English and are replying to an article written in English, what makes you decide to use another language?

Comment by Kiltak
2007-12-09 05:08:33
lol, well, the comments that are not in english are “pingbacks”… stuff about this article that were written on another blog. Wordpress writes a comment for each automatically when it receives notifications of such posts…
 
 
Comment by WTF
2007-12-09 09:21:17
Well I guess that makes sense. This is otherwise the kind of thing that makes foreigners look stupid, like the way they must feel when English-speakers act like shouting is going to magically cross a language barrier.
Comment by WTFx2
2008-03-24 22:37:33
I think you’re the one who is looking pretty stupid here now buddy for not knowing what a pingback is.
 
 
Comment by paulette Subscribed to comments via email
2007-12-12 05:24:34
Thanks for your suggestion.Im really annoyed by things i wanted to delete but i cant succesfully delete.And Im gald to find an answer from your article
 
Comment by Mukarram Subscribed to comments via email
2008-01-03 13:47:04
Really very helpful….
i wanna ask u somthin just for the blogger.com ..
if can we setup blogger blog locally on our windows system…..on windows xp …..just for d testing prupose ..
b4 making any online changes i wanna see dt on my system…
or is there any book to read for …or any other kinda help will be appreciated …..

thanks alot for being a geek dts so sexy …..

take care

mukarram

 
Comment by Blastedt
2008-01-03 17:18:23
Sometiems deleting all other files in a folder can do it. Once I got a virus/spyware/etc from MiniClip. Deleting the folder did not work, but deleting all but the undeletable file let me eventually delete the file. Although this was years ago, I remember that the folder contained, among other things, a few .txt’s or something mocking me.
 
Comment by Monkey Man
2008-01-17 10:26:16
I have a problem file that isn’t locked, but somehow has an invalid character embedded in the filename, so its not only inaccessible, its undeletable!

Some crappy Curtis MP3 software driver created the folder and file, I guess they were trying to keep it from accidental deletion or the installer was just buggy.

 
Comment by Kaptain
2008-01-18 07:25:44
I have a file (uye38.sys)that I can not unlock with unlocker,Ad aware starts then just reboots my computer,trojan remover finds it, but can not delete or rename it.I have tried to delete it at the command prompt says access denied (did not try with the disk yet)System restore says incomplele. When I try to open the file it comes up in notepad and says access is denied. Any one have help for this one?
 
Comment by Kaptain
2008-01-18 08:55:28
Maybe I should have tried the windows cd before I posted.
Who ever posted putting in the Win cd hit R and go to the recovery console and delete the file worked just fine.(Kiltalk I think) Thanks for that info…cool site, I’m glade I found my way here :) I did find out one thing though, Unlocker don’t always work :P
Thanks Again, Peace
 
Comment by Webmaster for Hire
2008-02-03 04:07:33
I never thought about killing explorer.exe, but you gave us a great tip. Many thanks friend.
 
Comment by asf
2008-02-04 13:22:46
Instead of recommending a product - why don’t you guys just tell us how to delete a locked file…how does the product delete a locked file ..MAGIC???? Are you guys selling SPELLS???!!!
 
Comment by xenno Subscribed to comments via email
2008-02-06 10:46:23
heres one for someone. I had a 600mg file that was trash (it was a directory that had an old version of windows in it that was archived.) since i don’t need it i figured i would delete it. put it in the trash bin and went to clear it out and walla it’s gone. next day i need to do a reboot delete a few txt files i don’t need and click delete and get an error, can’t delete c:/oldwinarchive/ acess denied blah blah blah. wow, open up my trash bin and … huh? no file. so i do it again, right click, delete and there is the error again! hmmm, i try to restore so i can do a manual delet and there’s no file to restore! hmm two weeks later i’m cleaning the ole drive again and delete a .iso i made (52 megs) of old trade rags in ebook format and when i right click hit delete and it’s gone. I then notice a web page i downloaded to read offline so i delete it and get a suprise, error cannot delete c:/offlinemags/aug2007.pdf access denied, but it’s not in the trash bin.

so anyone got an idea of where i should start with this? it seems to change filenames every so often. i have used unlocker when i needed to get rid of malware so i figured this was the place to ask.

 
Comment by Michael
2008-02-10 08:26:43
You didn’t cover DOS/windows reserved filenames. E.g. getting rid of a file named con.txt can be rather problematic.

Although there may be other means, I like the approach:
* shut the system down
* boot CD/DVD of a different operating
system - e.g. Knoppix, Ubuntu, etc.
* mount the applicable filesystem(s) rw
* change attributes on the file(s) if
necessary
* delete (rm(1)/unlink(2)) the file(s)
* unmount the filesystem(s)
* you’re done (reboot you DOS/windows, if
you really want)

The article also didn’t cover “undeletable” files on other operating systems.

 
Comment by Misha
2008-02-10 10:29:55
Thanks for the Unlocker reveal. That’s a great little piece of software and exactly what I was needing!
 
Comment by jason
2008-02-22 09:19:13
that unlocker program looks sweet
 
Comment by Chris
2008-03-17 07:12:59
One simple solution that I didn’t see anyone touch on is to use a direct hex editor. You can open pretty well any file, and while what it contains will be utter gibberish, if you just start stripping out lines of it the file becomes useless and it is very easy to delete at that point.
 
Comment by drsafemode
2008-03-29 02:31:19
Unlocker comes in very handy.
 
Comment by jack johnson
2008-04-06 01:49:41
i use unlocker, but useless… i`m looking for Delete FXP Files 2007…. help…
 
Comment by Sarah
2008-04-09 10:25:52
THANK YOU SO MUCH geeksaresexy.net! I’m so glad to be rid of that damned virus. :) Thank you
 
Comment by Ajay
2008-04-13 06:54:31
Thank you for the clear instructions!! I was able to delete the fdcatch.dll file by killing the Explorer.exe in Task manager.. but the folder itself had to be deleted after using Unlocker program. Thanks again :)
 
Comment by Jackie Subscribed to comments via email
2008-04-16 23:57:10
Pls…help ME I want to delete the file in my USB PEN DRIVE MEMORY but I can’t…
 
2008-04-23 02:15:52
[...] they published a small story: “How to delete a undeletabele or locked file“. One of the tips shows how useful is the Unlocker software. The small freeware is not only [...]
 
Comment by Q
2008-05-20 20:17:48
Excellent tips. I killed explorer.exe and managed to get rid of a file that otherwise refused to be deleted, despite reboots, Safe Mode and so on. Thanks =)
 
Comment by Panda
2008-06-26 17:35:25
I tried both of those things (actually, the first before finding this page) and this file will still not delete! Is there anything else to try?
 
Comment by Panda
2008-06-26 17:43:05
Oops, I mentI tried numbers 1 & 3, number 2 does no apply to me.
Comment by Kiltak
2008-06-26 17:57:13
It doesn’t apply to you? And why is that? You are running a windows system aren’t you?
 
 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.