Tuesday, May 5, 2009

Haja Peer Mohamed H

Delete Files In Use On Windows Vista And Windows 7

There are times when Windows won’t let you delete a file, not because it’s in use, but because you don’t have permission. And remember, even though this article is based on Windows Vista Operating System, most solutions are still applicable to Windows 7. What it mean is, you can also try implement these solution on Windows 7 too.

Vista won’t let you delete a file, which is stupid because it’s your PC and you should be able to delete anything you want. So there. Of course, there are times when Vista does know better than you, and prevents you from deleting files that are currently in use to avoid causing crashes or data loss. An in-use file could be a document that’s currently open, a program executable that’s currently running, or a folder locked by a running application. 

Most of the time, you can get around this by closing the application or restarting Windows, but it’s not always that easy. For instance, if the program has crashed, you’ll need to use Task Manager to end the process; Or, if the program is actually a Windows service, you’ll need to use the Services window (services.msc) to stop the service before you’ll be allowed to delete the file.

But what if the file you’re trying to delete is part of a virus? Or what if you know the file isn’t open, but Vista still won’t let you delete it?


Solution 1: Use the Command Prompt
Windows Vista has a special way to get to the Command Prompt without loading most of the rest of the operating system, not to mention any applications or services (or viruses) that can come along for the ride. Once you’re there, use the del command to delete the file. When that’s done, close the Command Prompt window, or type exit and press Enter to restart your PC and load Windows. 



Solution 2: Use Wininit.ini
If you don’t want to use the Command Prompt, you can use another littleknown trick that takes advantage of a feature used by application installers to replace program files. First, open Windows Explorer and navigate to your C:\Windows folder. Double-click the Wininit.ini file to open it in Notepad (or any other standard plain-text editor). If the file isn’t there, just create a new empty text file, name it Wininit.ini, and type the following line at the top: 

[rename] 

(In most cases, the Wininit.ini file will exist but will be empty, with the exception of the [rename] line; any other lines you see here would’ve been added by a recent application installation.) Under the [rename] section header, type the following line: 

NUL=c:\folder\filename.ext 

where c:\folder\filename.ext is the full path and filename of the file you wish to delete. You can specify as many files here as you want, one on each line. To replace a file rather than simply deleting it, the syntax is a little different:

c:\folder\existing.ext=c:\folder\replacement.ext 

where c:\folder\existing.ext is the full path and filename of the file you’re trying to replace, and c:\folder\replacement.ext is the full path and filename of the new file to take its place. If the file specified on the right side of the equals sign doesn’t exist, then the existing.ext file will be moved/renamed to c:\folder\replacement.ext. 

When you’re done, save the file, close Notepad, and restart Windows. The files will be deleted or replaced as you’ve specified during the startup procedure.

Haja Peer Mohamed H

About Haja Peer Mohamed H -

Haja Peer Mohamed H, Software Engineer by profession, Author, Founder and CEO of "bench3" you can connect with me on Twitter , Facebook and also onGoogle+

Subscribe to this Blog via Email :