Windows 7 WIN7 - temp folder clean up

artoo

Senior Member
Joined
Nov 10, 2009
Messages
19
Anyone know of a way to empty the temp folder (C:\Users\[USERNAME]\AppData\Local\Temp) on shutdown?
 


Solution
To automatically clear the contents of the temp folder (C:\Users[USERNAME]\AppData\Local\Temp) on shutdown, you can create a batch file that deletes the folder contents and then configure Windows to run this batch file on shutdown. Here's a step-by-step guide on how you can achieve this:

Step 1: Create a Batch File to Delete Temp Folder Contents​

  1. Open Notepad or any text editor.
  2. Copy and paste the following commands into the text editor:
    Code:
    batch @echo off RD /S /Q C:\Users\[USERNAME]\AppData\Local\Temp
    Replace [USERNAME] with your actual username.
  3. Save the file with a ".bat" extension, for example, "ClearTempFolder.bat".

    Step 2: Configure Windows to Run the Batch File on Shutdown​

  4. Press Win + R, type...
To automatically clear the contents of the temp folder (C:\Users[USERNAME]\AppData\Local\Temp) on shutdown, you can create a batch file that deletes the folder contents and then configure Windows to run this batch file on shutdown. Here's a step-by-step guide on how you can achieve this:

Step 1: Create a Batch File to Delete Temp Folder Contents​

  1. Open Notepad or any text editor.
  2. Copy and paste the following commands into the text editor:
    Code:
    batch @echo off RD /S /Q C:\Users\[USERNAME]\AppData\Local\Temp
    Replace [USERNAME] with your actual username.
  3. Save the file with a ".bat" extension, for example, "ClearTempFolder.bat".

    Step 2: Configure Windows to Run the Batch File on Shutdown​

  4. Press Win + R, type "gpedit.msc" and hit Enter to open the Group Policy Editor.
  5. Navigate to "Computer Configuration" -> "Windows Settings" -> "Scripts (Startup/Shutdown)".
  6. Double click on "Shutdown" on the right pane.
  7. Click on "Add" and then "Browse" to select the batch file created in Step 1.
  8. Click "OK" to save the settings.

    Note:​

    • The above steps are applicable to Windows Pro and Enterprise editions. If you are using Windows Home, you can achieve a similar result by editing the registry.
    • Be cautious when deleting system files, and ensure that the folder you want to delete is indeed the temp folder and not a critical system directory.
    • Deleting the temp folder contents on shutdown may impact the functioning of some applications that use the temp folder for temporary storage.
    By following these steps, you can automate the process of clearing the temp folder contents on shutdown. Let me know if you need further assistance!
 


Solution
Back
Top