Advertisement
Thoomas2873

delete temp files

Feb 13th, 2024
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.22 KB | Software | 0 0
  1. @echo off
  2.  
  3. :: BatchGotAdmin
  4. :-------------------------------------
  5. REM  --> Check for permissions
  6. >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  7.  
  8. REM --> If error flag set, we do not have admin.
  9. if '%errorlevel%' NEQ '0' (
  10.     echo Requesting administrative privileges...
  11.     goto UACPrompt
  12. ) else ( goto gotAdmin )
  13.  
  14. :UACPrompt
  15.     echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  16.     set params = %*:"=""
  17.     echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
  18.  
  19.     "%temp%\getadmin.vbs"
  20.     del "%temp%\getadmin.vbs"
  21.     exit /B
  22.  
  23. :gotAdmin
  24.     pushd "%CD%"
  25.     CD /D "%~dp0"
  26. :--------------------------------------
  27.  
  28.  
  29. @echo off
  30. color 6
  31.  
  32. REM Delete contents of C:\Windows\Temp
  33. set /a tempFilesDeleted=0
  34. for /f %%F in ('dir /b /a-d "C:\Windows\Temp\*" 2^>nul ^| find /c /v ""') do set "tempFilesDeleted=%%F"
  35. del /q /s /f "C:\Windows\Temp\*.*"
  36. for /d %%i in ("C:\Windows\Temp\*") do (
  37.     rmdir /s /q "%%i"
  38. )
  39.  
  40. timeout /t 5 >nul
  41. cls
  42. echo.
  43. echo.
  44. echo.
  45. echo.
  46. echo   DIAGRAFTIKE TO temp   /////     %tempFilesDeleted% files deleted from C:\Windows\Temp.
  47. echo.
  48. echo.
  49. echo.
  50. timeout /t 10 >nul
  51.  
  52. REM Delete contents of %temp% folder
  53. set /a userTempFilesDeleted=0
  54. for /f %%F in ('dir /b /a-d "%temp%\*" 2^>nul ^| find /c /v ""') do set "userTempFilesDeleted=%%F"
  55. del /q /s /f "%temp%\*.*"
  56. for /d %%i in ("%temp%\*") do (
  57.     rmdir /s /q "%%i"
  58. )
  59.  
  60. timeout /t 5 >nul
  61. cls
  62. echo.
  63. echo.
  64. echo.
  65. echo.
  66. echo   DIAGRAFTIKE TO \AppData\Local\Temp  /////     %userTempFilesDeleted% files deleted from \AppData\Local\Temp directory.
  67. echo.
  68. echo.
  69. echo.
  70. timeout /t 10 >nul
  71. REM Delete prefetch files
  72. set /a prefetchFilesDeleted=0
  73. for /f %%F in ('dir /b /a-d "%SystemRoot%\Prefetch\*" 2^>nul ^| find /c /v ""') do set "prefetchFilesDeleted=%%F"
  74. del /q /f /s "%SystemRoot%\Prefetch\*.*"
  75.  
  76.  
  77. timeout /t 5 >nul
  78. cls
  79. echo.
  80. echo.
  81. echo.
  82. echo.
  83. echo   DIAGRAFTIKE TO prefetch   /////     %prefetchFilesDeleted% files deleted from prefetch directory.
  84. echo.
  85. echo.
  86. echo.
  87. timeout /t 5 >nul
  88.  
  89.  
  90. REM Countdown for 10 seconds
  91. for /l %%i in (8,-1,1) do (
  92.     echo.
  93.     echo   Closing in %%i seconds...
  94.     timeout /t 1 >nul
  95. )
  96.  
Tags: bat .bat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement