Advertisement
FreeBooter

Clear_Temp.bat

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