Advertisement
Najeebsk

WIN-CLEANER.bat

Dec 10th, 2024
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.69 KB | None | 0 0
  1. rem This script was written by Najeeb Shah Kahn - Published in 2024
  2. rem email: najeebshahkhan@gmail.com
  3. cls
  4.  
  5. @echo off
  6. :: Check for admin privileges
  7. net session >nul 2>&1
  8. if %errorlevel% neq 0 (
  9.     echo Requesting administrator privileges...
  10.     powershell -Command "Start-Process '%~f0' -Verb RunAs"
  11.     exit /b
  12. )
  13.  
  14. rem Check If User Has Admin Privileges
  15. timeout /t 1 /nobreak > NUL
  16. openfiles > NUL 2>&1
  17. if %errorlevel%==0 (
  18.     echo Running..
  19. ) else (
  20.     echo You must run me as an Administrator. Exiting..
  21.     echo.
  22.     echo Right-click on me and select ^'Run as Administrator^' and try again.
  23.     echo.
  24.     echo Press any key to exit..
  25.     pause > NUL
  26.     exit
  27. )
  28.  
  29. echo.
  30.  
  31. rem Delete Temporary Files
  32. del /s /f /q %WinDir%\Temp\*.*
  33. del /s /f /q %WinDir%\Prefetch\*.*
  34. del /s /f /q %Temp%\*.*
  35. del /s /f /q %AppData%\Temp\*.*
  36. del /s /f /q %HomePath%\AppData\LocalLow\Temp\*.*
  37.  
  38. rem Delete Used Drivers Files (Not needed because already installed)
  39. del /s /f /q %SYSTEMDRIVE%\AMD\*.*
  40. del /s /f /q %SYSTEMDRIVE%\NVIDIA\*.*
  41. del /s /f /q %SYSTEMDRIVE%\INTEL\*.*
  42.  
  43. rem Delete Temporary Folders
  44. rd /s /q %WinDir%\Temp
  45. rd /s /q %WinDir%\Prefetch
  46. rd /s /q %Temp%
  47. rd /s /q %AppData%\Temp
  48. rd /s /q %HomePath%\AppData\LocalLow\Temp
  49.  
  50. rem Delete Used Drivers Folders (Not needed because already installed)
  51. rd /s /q %SYSTEMDRIVE%\AMD
  52. rd /s /q %SYSTEMDRIVE%\NVIDIA
  53. rd /s /q %SYSTEMDRIVE%\INTEL
  54.  
  55. rem Recreate Empty Temporary Folders
  56. md %WinDir%\Temp
  57. md %WinDir%\Prefetch
  58. md %Temp%
  59. md %AppData%\Temp
  60. md %HomePath%\AppData\LocalLow\Temp
  61. nircmd.exe emptybin
  62. echo.
  63. echo Windows Clean Up Done!, You can exit by pressing any key.
  64. echo.
  65. echo Najeeb Running as administrator!
  66. pause > NUL
  67. exit
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement