C
C
CG Artist2020-04-13 11:18:28
Automation
CG Artist, 2020-04-13 11:18:28

How to automate the cleanup of TEMP folders?

Hello Khabrovites!

I tried to automate the cleaning of TEMP folders according to instructions from one site.

5e941e9552137459261631.png
По этой статьей: https://remontcompa.ru/windows/windows-10/179-papk...
— пытался настроить очистку папок TEMP перед выходом из системы, командой в «Редакторе локальных групповых политик».
But, when you exit the system (restart or shutdown), all desktop elements disappear, only the desktop wallpaper and the cursor (which can be moved, it does not freeze) are displayed - the computer can be in this position for a long time and nothing happens, as if it freezes.

Therefore, I am looking for another solution, how it would be possible to automate the cleaning of TEMP folders (I think before logging out the most convenient moment for this).

(I have Windows 7)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Hemul GM, 2020-04-13
@Sannyasin

1. She cleans herself anyway.
2. The Windows Scheduler allows you to create tasks that will respond to specific events, such as the entry or exit (possibly) of a user. Create a batch or cmd script to clean up the directory. We create a task in the scheduler, select an event and a script.
3. Cleaning up at logout is a very bad idea because the session is ending, and you want to multiply tasks. The task can be forced to end without completing its task or slow down the shutdown.

K
Konstantin Tsvetkov, 2020-04-13
@tsklab

I create one folder C:\Temp, the rest

C:\ProgramData\Temp
C:\Users\tsk\AppData\Local\Temp
C:\Users\tsk\AppData\LocalLow\Temp
C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp
C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp
C:\Windows\Temp

they are symbolic links.
I define:
SET TEMP=C:\Temp\
SET TMP=C:\Temp\

I draw attention to the slash at the end - this is a protection against programmers who forget to add this slash when creating temporary files in programs (Adobe Photoshop, for example).
Cleaning (task "on login"):
echo ------ clear TEMP
del /S /Q %TEMP%\*.*
rmdir /S /Q %TEMP%
rmdir /q /s "H:\msdownld.tmp"
powershell -NoLogo -command "& Clear-RecycleBin -force" 2>NUL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question