Advertisement
FreeBooter

Clear_Temp

Sep 20th, 2016
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 6.04 KB | None | 0 0
  1. :: Batch Script Created by FreeBooter
  2. @Echo Off & Cls
  3. Call :IsAdmin
  4.  
  5. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  6.  
  7. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\BranchCache" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  8.  
  9. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  10.  
  11. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  12.  
  13. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  14.  
  15. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  16.  
  17. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  18.  
  19. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  20.  
  21. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  22.  
  23. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  24.  
  25. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  26.  
  27. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  28.  
  29. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  30.  
  31. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  32.  
  33. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  34.  
  35. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Update Cleanup" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  36.  
  37. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  38.  
  39. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\User file versions" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  40.  
  41. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Defender" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  42.  
  43. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  44.  
  45. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  46.  
  47. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  48.  
  49. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  50.  
  51. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows ESD installation files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  52.  
  53. Reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files" /v "StateFlags0064" /t REG_DWORD /d "2" /f 2>&1 >nul
  54.  
  55. ::    CLEANUP STAGE
  56.  
  57. Cls & Mode CON  LINES=6 COLS=50 & Color 1E & Title Created by FREEBOOTER
  58. Echo.
  59. Echo.
  60. Echo.
  61. Echo.
  62. Echo.
  63. Echo.
  64. Echo.
  65. Echo.
  66. Echo.
  67. Echo.
  68. Echo.
  69. Echo.
  70. Echo.
  71. Echo.
  72. Echo.
  73. Echo           ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  74. Echo           º DELETING TEMPORARY FILES º  
  75. Echo           ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  76. Echo.
  77. Taskkill  /IM Explorer.exe /f
  78. CLEANMGR /sagerun:64
  79.  
  80.  
  81.  
  82. Cls
  83. :: Clear Temporary Folder.
  84. Cd %TMP%
  85. For /f "tokens=*" %%a in ('Dir /b %LOCALAPPDATA%\Temp') do (
  86. Echo Y | Rd /s /q "%%a" 2>NUL 1>NUL
  87. If Exist "%%a" Echo Y | Del /a /f "%%a" 2>NUL 1>NUL
  88. )
  89. Echo.
  90. Echo.
  91. Echo.
  92. Echo.
  93. Echo.
  94. Echo.
  95. Echo.
  96. Echo.
  97. Echo.
  98. Echo.
  99. Echo.
  100. Echo.
  101. Echo.
  102. Echo        FINNISH DELETING TEMPORARY FILES
  103. Echo.
  104. Echo.
  105. ping -n 6 localhost >Nul
  106.  
  107.  
  108. Cls
  109. Cls & Mode CON  LINES=12 COLS=80 & Color 1E & Title Created by FREEBOOTER
  110. Reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName | find /i "Windows 8" >Nul
  111. If Not Errorlevel 1 (
  112. Dism /Online /Cleanup-Image /StartComponentCleanup
  113. ) Else (
  114. Reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName | find /i "Windows 8.1" >Nul
  115. If Not Errorlevel 1 (
  116. Dism /Online /Cleanup-Image /StartComponentCleanup
  117. ) Else (
  118. Reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName | find /i "Windows 10" >Nul
  119. If Not Errorlevel 1 (
  120. Dism /Online /Cleanup-Image /StartComponentCleanup
  121. ) Else (   
  122. Goto :Event_Log
  123. ) ) )  
  124.  
  125. Ping -n 4 localhost >Nul
  126. Goto :Event_Log
  127.  
  128.  
  129.  
  130.  
  131. :IsAdmin
  132. Reg query "HKU\S-1-5-19\Environment"
  133. If Not %ERRORLEVEL% EQU 0 (
  134.  Cls & Mode CON  LINES=5 COLS=48 & Color 0C & Title - WARNING -
  135.  Echo.
  136.  Echo.
  137.  Echo  YOU MUST HAVE ADMINISTRATOR RIGHTS TO CONTINUE
  138.  Pause >Nul & Exit
  139. )
  140. Cls
  141. Goto :EOF
  142.  
  143.  
  144.  
  145. :Event_Log
  146. Cls
  147. Mode CON  LINES=33 COLS=85
  148. For /F "tokens=*" %%G in ('wevtutil.exe el') DO (call :do_clear "%%G")
  149. Echo.
  150. Echo                    Event Logs Have Been Cleared!
  151. Start Explorer.exe
  152. Ping -n 5 127.0.0.1 >Nul
  153. Goto :eof
  154. :do_clear
  155. Echo clearing %1
  156. wevtutil.exe cl %1
  157. Goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement