avhimkov
8/12/2016 - 9:53 AM

ClerTEMP

ClerTEMP

@echo off

IF EXIST c:\windows\temp\ del /f /s /q c:\windows\temp\

DEL /f /s /q %temp%\

IF EXIST "C:\Users\" (
    for /D %%x in ("C:\Users\*") do ( 
        del /f /s /q "%%x\AppData\Local\Temp\"
	    del /f /s /q "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files\" 
		
    )
)

IF EXIST "C:\Documents and Settings\" (
    for /D %%x in ("C:\Documents and Settings\*") do ( 
        del /f /s /q "%%x\Local Settings\Temp\" 
        del /f /s /q "%%x\Local Settings\Temporary Internet Files\" 
    )
)

IF EXIST "C:\Users\" (
    for /D %%x in ("C:\Users\*") do ( 
        rmdir /s /q "%%x\AppData\Local\Temp" 
        mkdir "%%x\AppData\Local\Temp" 
        rmdir /s /q "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files" 
        mkdir "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files" 
    )
)

pause
pushd %TEMP% && rd /s /q . > nul 2>&1
pushd %WinDir%\TEMP && rd /s /q . > nul 2>&1
@echo off
SetLocal EnableExtensions

For /F "Tokens=2*" %%I In ('Reg Query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /V ProfilesDirectory') Do Set Profiles=%%J
Call Set Profiles=%Profiles%

For /F "Delims=" %%I In ('Dir /B /AD-S-H "%Profiles%" ^| FindStr /V /B /I /C:"All Users"') Do (
  Del /F /S /Q "%Profiles%\%%I\Local Settings\Temp\*.*"
  Del /F /S /Q "%Profiles%\%%I\Local Settings\Temporary Internet Files\*.*"
  
  Del /F /S /Q "%Profiles%\%%I\AppData\Local\Temp\*.*"
  pushd "%Profiles%\%%I\AppData\Local\Temp\" && rd /s /q . > nul 2>&1
  Del /F /S /Q "%Profiles%\%%I\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*"

  pushd %WinDir%\TEMP && rd /s /q . > nul 2>&1
  Del /F /S /Q "%WinDir%\TEMP\*.*"
)