Kioskea
Recherche
Ask a question »

A batch file to delete temp user files

March 2015

A Windows batch file is a type of text file, which contains a series of commands for a computer's operating system. You should not open batch files on your hard disk that are unknown as they contain executable commands. The file extension for batch file is .BAT. The Temp files (Temporary files) are created by system programs essentially when the programs cannot get the appropriate level of memory to complete a task. Using batch files you can view, access and erase the content of the temporary files as you would do in the Command prompt by typing a specific set of commands.

A batch file to delete temp users files




Issue


I'm trying to create a batch file to clean my business PC (such as the contents of Temp files and Temporary Internet Files for each user...)

Solution


This script deletes all files in
  • C:\Documents And Settings\<UserName>\Local settings\Temp and
  • C:\Documents And Settings\<UserName>\Local settings\Temporary Internet Files

@echo off   
cd /d %temp%   
for /r %%a in (*.*) do (   
del /f /q %~a   
) >nul   
cd /d "%UserProfile%\Local Settings\Temporary Internet Files   
for /r %%b in (*.*) do (   
del /f /q %~b   
) >nul   


Thanks to theo7777 for this tip.
For unlimited offline reading, you can download this article for free in PDF format:
A-batch-file-to-delete-temp-user-files.pdf

See also

In the same category

Published by deri58 - Latest update by Virginia Parsons
This document entitled « A batch file to delete temp user files » from Kioskea (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.