2

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?

Thanks

2
  • 3
    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, 2012 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, 2012 at 16:21

3 Answers 3

2

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"
0
0

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
2
  • 2
    Note the quotes around the command. PenguinCoder put them there in case the username contained whitespace.
    – Hennes
    Oct 26, 2012 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. Oct 26, 2012 at 16:33
0

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

You must log in to answer this question.

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