Helping people with computers... one answer at a time.

Windows will prevent you from deleting a file that's in use by a running program. If you can't find or shut down the program a different approach is needed.

AVG Anti-virus keeps telling me that I have a threat in the file C:\WINDOWS\cdsnp1.dll. AVG can't quarantine or delete it - it says that it cannot access to the file. If I try, it tells me something about the file being in use. What do I do?

This is likely one of the many manifestations of a very common problem. No, not the virus - I honestly have no idea what that is. I mean the inability of a program, or even you, to delete a file because it's in use.

In some cases Windows prevents you from deleting files because they're in use by some program running on your machine - often Windows itself. Deleting it while in use by a running program could crash your machine, or worse.

So what if you know you need to delete a file, but it's in use from the very moment you boot your system, and no matter what software you shut down it's still "in use"?

Windows also provides the ability to perform actions when it boots - before any programs are running. How this is specified is fairly obscure, and not something you want to deal with directly (it's buried in the registry, if you're really curious). Fortunately, there's a free utility to do it for you.

MoveOnBoot is a free download that allows you to rename, copy or delete a file the next time you reboot your machine.

When run, MoveOnBoot asks you to specify a file:

MoveOnBoot - specify filename

In this case I've selected the file c:\t\pagra.txt.

Hit next, and you'll get a choice:

MoveOnBoot - specify action

"Do not delete any Windows system files or your system may become unbootable ..."

It's called MoveOnBoot because the most common, and perhaps safest action is not to delete the file, but rather rename it or move it to a different folder so that the program that eventually tries to load it won't find it. However, you can also instead make a copy of the file, or truly delete the file, if you so choose.

In my case, I'll select "Move", and then it asks:

MoveOnBoot - specify move destination

I've left the location the same (c:\t), but simply changed the name of the file.

Finally, MoveOnBoot confirms what it's about to do:

MoveOnBoot - confirmation

Even though it says "Start", it simply schedules the action to occur the next time you reboot.

Now, when you reboot your machine, once it comes back up, the file specified will be renamed, (or deleted or copied, depending on what you specified) before any other program has an opportunity to place it "in use".

CAUTION: you can really hurt your system using this utility. Do not delete any Windows system files or your system may become unbootable and you'll need to reinstall Windows from your installation media.

Use this utility with care.

Article C2828 - November 2, 2006

Leo Leo A. Notenboom has been playing with computers since he was required to take a programming class in 1976. An 18 year career as a programmer at Microsoft soon followed. After "retiring" in 2001, Leo started Ask Leo! in 2003 as a place for answers to common computer and technical questions. More about Leo.

Not what you needed?

Recent Comments
17 Comments

I had a problem deleting a malware DLL that seemed impervious to the above ideas. I finally got rid of it by setting the security permissions to Deny Execute. Next time I rebooted, the dll was unable to load, and could be deleted.

Posted by: Paul at September 8, 2007 7:10 PM

Thanks for this, worked a treat on a file that McAfee marked as a Trojan but could not delete.

Posted by: David at September 18, 2008 3:28 AM

Hi, this is a little long, but I hope you could help me. And yes it is related to moveonboot, since it won't delete the file I need it to.
Somehow I got the SecurityTool virus installed in my computer, after an exhausting war against it I manage to delete it. But afterwards it seems that a good number of malwares found their way in my computer. One of them took the name of one of my folders and added .exe at the end, and is this particular one I'm trying to delete, it says I can't because is in use somewhere.
I read the other article about procexp and downloaded it. I've found the handdle (there were 6 with the same name) but after I click on it everything is highlighted and I don't know which process to end.
So I saw this article and downloaded moveonboot, I've installed it, and so far so good, but when I try to delete it, or rename it, moveonboot denies me the acess or something like that. In other words, it can be done.
Any antivirus, antimalware, antispyware can delete this thing... So if you could help me, I'd be reaaaaaally thankful. Seriously!

Posted by: Natasha at September 26, 2010 8:08 PM

Hi, this program formatted my hard drive.
DO NOT USE!

Posted by: colin at November 4, 2010 11:37 AM

This often works when MoveOnBoot fails.

http://unlocker.en.softonic.com/

Posted by: Mark J at February 20, 2011 1:30 AM
Post a comment on "How do I delete a file in use?":





Remember Me?

(You may use HTML tags for style)

Before commenting, please...

  • READ THE ARTICLE. A comment that shows you didn't will be deleted and ignored.

  • Comment only on the article. Use the search box at the top of the page if you have a question about something else.

  • NO PERSONAL INFORMATION in the comment. No email addresses. No phone numbers. No physical addresses.

  • Anything that looks the least bit like spam will be deleted. Links to unrelated sites or links that appear to be primarily promotional will be deleted, or the comment will be deleted.

  • Don't ask me to recover lost passwords or hacked accounts. I can't. Those comments will be deleted.

  • I can't respond to every comment. And I can't vouch for the accuracy of others who do.

Please wait. Your comment is being processed ...