Question: Why can't I delete certain files as Admin on my windows machine? ~ Ask The Admin

Thursday, July 19, 2007

Question: Why can't I delete certain files as Admin on my windows machine?

Got hit with spyware? Someone hit your ftp with funny looking files And now you can't delete them? Here is the solution right from GeeksAreSexy

Quick Edit here are the responses from our readers first. We love to offer multitudes of solutions :)...

Process Explorer from Sysinternals, now MS, is like Task Manager on 'the cream and clear' as Barry Bonds would call it.

In there it will tell you every process that is running, even services and all the files that are running them, and where they are located. It allows you to suspend and kill the process and all related/affiliated processes, so you can then go and delete the files in question.

...

I did refer to my manual and lookie what I found:

In Windows XP we use RD as well it replaced deltree.

Removes (deletes) a directory

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

/S Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree.



/Q Quiet Mode, do not ask f ok to remove a directory tree with /S

...

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 spyware, and some of the spyware’s DLLs get locked by the system. Have you ever tried deleting a locked file using common windows command? It’s 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!