Some applications fail to clean up after themselves and delete the temporary files they have created in those temporary directories. After a while those directories may be filled with several tens to hundreds of megabytes of unneeded files. The process of cleaning up the temporary directories can be automated with the following command in the AUTOEXEC.BAT file.
DELTREE /y c:\temp\
Several important observations have to be made regarding the DELTREE command.
Be extremely cautious in using the DELTREE command since it will delete all files and directories indicated, even read-only, system, and hidden files and directories.
The '/y' option eliminates the request for confirmation if you want to delete the directory or one of its subdirectories. This is required for automated execution in a batch file. It also makes the destructive impact of the command much greater, since the user has no change to interrupt the execution of the DELTREE command.
The trailing backslash in the path indicating the directory holding the temporary files is important, because without it the DELTREE command will delete all the files in the temporary directory and its subdirectories and remove the temporary directory. When the temporary directory is missing, some applications might fail to start.
Deleting temporary files should be done before Windows is started or after Windows has terminated. Once Windows and some of its applications are running, one or more temporary files might be in use by these applications and should not be deleted.