Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently trying to use the del or the erase command in a RSM Telnet to delete Temp files on users computers. But the problem I'm running into with the command is that it is working, but won't delete any of the files located in the temp folder.

Command I'm using : erase c:\users\[username]\appdata\local\temp

I have used the command with the /p to prompt me, but some of these temp folders have thousands of files in them and sitting there and pressing Y and then enter endlessly is not going to work, because I have around 90 computers to clean temp files on. Is there something wrong with the command or is there a simpler command to use to delete the temp files on the computer?


share|improve this question
Use the windows and command-line tags, not the ms-dos tag, unless you are talking about the operating system called MS-DOS. Windows is not (based on) MS-DOS and has had nothing to do with it since 98/ME. 2000/XP were based on the Windows NT kernel! – Bob Oct 26 '12 at 16:20
True. And it needs to be said (same as megabit (Mb) vs megaByte (MB)). But many people confuse the cmd.exe shell with MSDOS. – Hennes Oct 26 '12 at 16:21
up vote 2 down vote accepted

This is what I have in a batch file I wrote called cleantemp.bat. It uses the current value of the TEMP environment variable to get the path to the temp folder, but you could use another one (like TMP) or hardcode one into it if you wished.

:: Quietly (with no prompts) remove all files in temp folder (to remove files
:: in subfolders add /S option)
del /Q "%TEMP%\*.*"

:: Remove any TEMP folder subdirectories
for /D %%a in ("%TEMP%\*.*") do rd /Q /S "%%~fa"
share|improve this answer
Thank you! This works like a champ – Robert A Palmer Oct 26 '12 at 17:15

Try using the following:

del /Q /F "c:\users\[username]\appdata\local\temp"

From del /?

/F            Force deleting of read-only files.
/Q            Quiet mode, do not ask if ok to delete on global wildcard
share|improve this answer
Note the quotes around the command. PenguinCoder put them there in case the username contained whitespace. – Hennes Oct 26 '12 at 16:20
Ran the command with /q and /f and it deleted two more files, but there are still over 1900 files that are in there that cannot be deleted. – Robert A Palmer Oct 26 '12 at 16:33

Use rd/s/q Temp to remove the directory with contents.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .