This is such a simple thing that nobody would ever consider writing a blog entry or howto about it, right? The thing is though, I frequently see IT support technicians using Windows Explorer, clicking through into the user’s temp folder, highlighting everything and attempting to delete. They are interrupted (and the process aborted) by a message stating that a particular file was in use and could not be deleted, so they de-select that one file, and try again. Some more files are deleted but once again they are interrupted and told that another file couldn’t be deleted. They de-select that file and try again. This can go on for ages..
Here’s how to do it properly.
Go to a command prompt (Start -> Run -> cmd [enter])
At the command prompt type:
cd %tmp%
and press enter. This will change you into the current user’s temp directory.
AT THIS POINT, PLEASE MAKE SURE THAT THE PROMPT HAS CHANGED TO THE TEMP DIRECTORY. IF THERE IS ANY KIND OF ERROR, OR THE PROMPT DOESN’T CHANGE, DO NOT CONTINUE ON WITH THE NEXT COMMAND. I DO NOT WANT YOU TO REMOVE THE WRONG DIRECTORY!
Then type:
rd /s .
(that’s rd space slash-S space dot)
then press enter. Don’t forget the . at the end. This means “remove the current directory and all subdirectories, including all files.”
What will happen is that the contents of the temp directory and all subdirectories will be removed, but not the temp directory itself, because you are currently working in that directory (via the CD command) and therefore it can’t be deleted.
You’ll receive access denied messages for all in-use files, plus the temp directory itself. That’s fine. Those access denied messages would have been showstoppers if you were using Windows Explorer.
The above is clearing out the current user’s temp directory, which is located within that user’s profile directory (Documents and Settings\username). To clear out the system temp directory, which is located under the Windows directory, type:
cd %windir%\temp
(that’s CD, space, %windir%\temp)
and press enter. This will change you into the Windows temp directory.
AT THIS POINT, PLEASE MAKE SURE THAT THE PROMPT HAS CHANGED TO THE TEMP DIRECTORY. IF THERE IS ANY KIND OF ERROR, OR THE PROMPT DOESN’T CHANGE, DO NOT CONTINUE ON WITH THE NEXT COMMAND. I DO NOT WANT YOU TO REMOVE THE WRONG DIRECTORY!
Then just like before, type:
rd /s .
All done! You can type “exit” to close the command prompt.
Comments (6)