Skip to content

Instantly share code, notes, and snippets.

@devomman
Last active August 18, 2024 12:44
Show Gist options
  • Save devomman/97eb5eef2292148ce0a70cbe09be76b6 to your computer and use it in GitHub Desktop.
Save devomman/97eb5eef2292148ce0a70cbe09be76b6 to your computer and use it in GitHub Desktop.
Windows 10/11 clear command using batch file by DevOmman
@echo off
:: (Run as Admin code starts)
REM Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\icacls.exe" "%SYSTEMROOT%\system32\config\system"
REM If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Now Running As Administrative Privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:: (Run as Admin code ends)
::=======================================
::=======================================
:: (Your code is start from here:)
::===========================>
@echo off
color 1E
Title Clear Command by Omman
echo This delete will stop your update running service and deleting "Update files"
echo Are your sure want to clean and delete files?
Pause
echo.
cls
echo.
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: = 1%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo Last Clear Time: %DATE% %TIME% >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 1) Current Windows Temp Folder files >>"C:\Users\Public\Desktop\Log.txt"
Tree %windir%\Temp /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 1) Deleting Windows Temp Folder >>"C:\Users\Public\Desktop\Log.txt"
del /s /f /q %windir%\Temp\*.* >>"C:\Users\Public\Desktop\Log.txt"
rd /s /q %windir%\Temp >>"C:\Users\Public\Desktop\Log.txt"
md %windir%\Temp >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: == 2%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 2) Current Local %Temp% Folder files >>"C:\Users\Public\Desktop\Log.txt"
Tree %USERPROFILE%\APPDATA\Local\Temp /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 2) Deleting Local %Temp% Folder >>"C:\Users\Public\Desktop\Log.txt"
del /s /f /q %Temp%\*.* >>"C:\Users\Public\Desktop\Log.txt"
rd /s /q %Temp% >>"C:\Users\Public\Desktop\Log.txt"
md %Temp%\ >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: == 3%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 3) Current Windows Prefetch Folder files >>"C:\Users\Public\Desktop\Log.txt"
Tree %windir%\Prefetch /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 3) Deleting Windows Prefetch Folder >>"C:\Users\Public\Desktop\Log.txt"
del /s /f /q %windir%\Prefetch\*.* >>"C:\Users\Public\Desktop\Log.txt"
rd /s /q %windir%\Prefetch >>"C:\Users\Public\Desktop\Log.txt"
md %windir%\Prefetch >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: === 10%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 4) Current User Local Setting Temp Folder files >>"C:\Users\Public\Desktop\Log.txt"
Tree %USERPROFILE%\APPDATA\Local\Temp /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 4) Deleting User Local Setting Temp Folder >>"C:\Users\Public\Desktop\Log.txt"
del /s /f /q "%USERPROFILE%\Local Settings\Temp"\*.* >>"C:\Users\Public\Desktop\Log.txt"
rd /s /q "%USERPROFILE%\Local Settings\Temp" >>"C:\Users\Public\Desktop\Log.txt"
md "%USERPROFILE%\Local Settings\Temp" >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ==== 15%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 5) Current Recent Folder from Windows 10/11 only files >>"C:\Users\Public\Desktop\Log.txt"
Tree "%APPDATA%\Microsoft\Windows\Recent" /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 5) Deleting Recent Folder from Windows 10/11 only >>"C:\Users\Public\Desktop\Log.txt"
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent"\*.* >>"C:\Users\Public\Desktop\Log.txt"
rd /s /q "%APPDATA%\Microsoft\Windows\Recent" >>"C:\Users\Public\Desktop\Log.txt"
md "%APPDATA%\Microsoft\Windows\Recent" >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ===== 20%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 6) Current Recent Explor Folder from Windows 10/11 only files >>"C:\Users\Public\Desktop\Log.txt"
Tree "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations" /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 6) Deleting Recent Explor Folder from Windows 10/11 only >>"C:\Users\Public\Desktop\Log.txt"
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations"\*.* >>"C:\Users\Public\Desktop\Log.txt"
rd /s /q "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations" >>"C:\Users\Public\Desktop\Log.txt"
md "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations" >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ====== 25%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 7) Current Recent Custom Explor Folder from Windows 10/11 only files >>"C:\Users\Public\Desktop\Log.txt"
Tree "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations" /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 7) Deleting Recent Custom Explor Folder from Windows 10/11 only >>"C:\Users\Public\Desktop\Log.txt"
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations"\*.* >>"C:\Users\Public\Desktop\Log.txt"
rd /s /q "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations" >>"C:\Users\Public\Desktop\Log.txt"
md "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations" >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ======= 30%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 8) Current Run Command History from Registry files >>"C:\Users\Public\Desktop\Log.txt"
REG Query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 8) Deleting Run Command History from Registry >>"C:\Users\Public\Desktop\Log.txt"
REG Query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU >>"C:\Users\Public\Desktop\Log.txt"
REG Delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU /VA /F >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ======== 35%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 9) Current Run Command History from Registry files >>"C:\Users\Public\Desktop\Log.txt"
REG Query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 9) Deleting Path History from File Explorer Registry >>"C:\Users\Public\Desktop\Log.txt"
REG Delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths /VA /F >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ========= 40%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 10) Current Windows Prefetch Folder files >>"C:\Users\Public\Desktop\Log.txt"
Tree %windir%\Prefetch /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 10) Deleting Windows Prefetch Folder >>"C:\Users\Public\Desktop\Log.txt"
del C:\Windows\Prefetch\*.* /Q >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ========== 45%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 11) Current Windows .bak files >>"C:\Users\Public\Desktop\Log.txt"
Tree %windir%\Prefetch /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 11) Deleting Windows .bak files >>"C:\Users\Public\Desktop\Log.txt"
del /s /q /f c:\*.bak >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait Almost Done...
echo ----------------------------------
echo Progress: =========== 50%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 12) Current Windows Update Download files >>"C:\Users\Public\Desktop\Log.txt"
Tree %windir%\softwaredistribution /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 12) Deleting Current Windows Update Download files >>"C:\Users\Public\Desktop\Log.txt"
net stop wuauserv >>"C:\Users\Public\Desktop\Log.txt"
rmdir %windir%\softwaredistribution /s /q >>"C:\Users\Public\Desktop\Log.txt"
net start wuauserv >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ============ 55%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 13) Current Recyclebin files >>"C:\Users\Public\Desktop\Log.txt"
Tree c:\$Recycle.bin /F /A >>"C:\Users\Public\Desktop\Log.txt"
Tree d:\$Recycle.bin /F /A >>"C:\Users\Public\Desktop\Log.txt"
Tree e:\$Recycle.bin /F /A >>"C:\Users\Public\Desktop\Log.txt"
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo 13) Deleting Recyclebin Files >>"C:\Users\Public\Desktop\Log.txt"
del c:\$Recycle.bin\*.* /f /s /q >>"C:\Users\Public\Desktop\Log.txt"
del d:\$Recycle.bin\*.* /f /s /q >>"C:\Users\Public\Desktop\Log.txt"
del e:\$Recycle.bin\*.* /f /s /q >>"C:\Users\Public\Desktop\Log.txt"
call powershell.exe Clear-RecycleBin -force -ErrorAction:Ignore >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait Almost Done...
echo ----------------------------------
echo Progress: ============== 60%%
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait Almost Done...
echo ----------------------------------
echo Progress: =============== 65%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ================ 70%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ================== 80%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: =================== 85%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ==================== 90%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ===================== 95%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ====================== 100%%
echo ----------------------------------
GOTO END
:END
cls
echo.
echo.
echo Clear Files Successfully complete...
echo ----------------------------------
echo Progress: ====================== 100%%
echo.
echo.
Color 1A
echo ===========================================================================================
echo Last Clear Time: %DATE% %TIME%
echo ===========================================================================================
for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
echo ===========================================================================================%ESC%[1;31m
echo Deleting Temp, Prefetch, Recent, Windows Update Files, Empty Recyclebin, Explor Folder, Run Command, .bak%ESC%[1;32m
echo ===========================================================================================
echo Please Check this Deleting History Log file Where you Run this Command from a Folder
echo ===========================================================================================%ESC%[1;31m
echo Contact me as [email protected] If you need any help..Thanks
echo Do Not Delete This Folder Or It Contents.
echo ====================================================================================================================
echo %windir%\installer
Pause
@imbharat420
Copy link

Access denied while accessing log.txt

https://snipboard.io/VEOHTc.jpg

@devomman
Copy link
Author

@imbharat420 Please run this command as Mouse > Right Click > Run As Administrator and ignore if there is some access denied permission, it will work for your history and temp, bulk file remove easy way.
Note: This Command will work for Windows 10/11 only but Other Operating System Fully Accessed. Thanks.

@Shamim-Ul-Islam-Shihab
Copy link

Your batch file is really very useful!

But when I run this, a Log.txt file is coming to the Desktop Homepage!

I do not want Log.txt to come to my Desktop Homepage!

How can I remove this from the code?
@devomman

@devomman
Copy link
Author

@Shamim-Ul-Islam-Shihab
If you want without reporting the logs for you just edit the code and remove all line ex. below
echo =========================================================================================== >>"C:\Users\Public\Desktop\Log.txt"
and this line
>>"C:\Users\Public\Desktop\Log.txt"

@Shamim-Ul-Islam-Shihab
Copy link

1

When I press any key to continue, this notepad opens again!

NB: I have deleted the 2 commands you told me!

@devomman

@Shamim-Ul-Islam-Shihab
Copy link

Shamim-Ul-Islam-Shihab commented Nov 15, 2023 via email

@devomman
Copy link
Author

@Shamim-Ul-Islam-Shihab
Please save your notepad as ex.
image
then select the example.bat file > mouse right click > Choose "Run as Administrator"

@devomman
Copy link
Author

@Shamim-Ul-Islam-Shihab
Copy link

@echo off

:: (Run as Admin code starts)
REM Check for permissions

nul 2>&1 "%SYSTEMROOT%\system32\icacls.exe" "%SYSTEMROOT%\system32\config\system"

REM If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Now Running As Administrative Privileges...
goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

"%temp%\getadmin.vbs"
exit /B

:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:: (Run as Admin code ends)
::=======================================
::=======================================

:: (Your code is start from here:)
::===========================>

@echo off
color 1E
Title Clear Command by Omman
echo This delete will stop your update running service and deleting "Update files"
echo Are your sure want to clean and delete files?
Pause
echo.
cls
echo.
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: = 1%%
echo =========================================================================================== >>"C:
\Users\Public\Desktop\Log.txt"
echo Last Clear Time: %DATE% %TIME%
echo =========================================================================================== >>"C:
echo 1) Current Windows Temp Folder files >>
Tree %windir%\Temp /F /A
echo 1) Deleting Windows Temp Folder
del /s /f /q %windir%\Temp*.*
rd /s /q %windir%\Temp
md %windir%\Temp
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: == 2%%

echo 2) Current Local %Temp% Folder files
Tree %USERPROFILE%\APPDATA\Local\Temp /F /A

echo 2) Deleting Local %Temp% Folder
del /s /f /q %Temp%*.*
rd /s /q %Temp%
md %Temp%\
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: == 3%%

echo 3) Current Windows Prefetch Folder files
Tree %windir%\Prefetch /F /A

echo 3) Deleting Windows Prefetch Folder
del /s /f /q %windir%\Prefetch*.*
rd /s /q %windir%\Prefetch
md %windir%\Prefetch
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: === 10%%

echo 4) Current User Local Setting Temp Folder files
Tree %USERPROFILE%\APPDATA\Local\Temp /F /A

echo 4) Deleting User Local Setting Temp Folder
del /s /f /q "%USERPROFILE%\Local Settings\Temp"*.*
rd /s /q "%USERPROFILE%\Local Settings\Temp"
md "%USERPROFILE%\Local Settings\Temp"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ==== 15%%

echo 5) Current Recent Folder from Windows 10/11 only files
Tree "%APPDATA%\Microsoft\Windows\Recent" /F /A

echo 5) Deleting Recent Folder from Windows 10/11 only
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent"*.*
rd /s /q "%APPDATA%\Microsoft\Windows\Recent"
md "%APPDATA%\Microsoft\Windows\Recent"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ===== 20%%

echo 6) Current Recent Explor Folder from Windows 10/11 only files
Tree "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations" /F /A

echo 6) Deleting Recent Explor Folder from Windows 10/11 only
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations"*.*
rd /s /q "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations"
md "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ====== 25%%

echo 7) Current Recent Custom Explor Folder from Windows 10/11 only files
Tree "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations" /F /A

echo 7) Deleting Recent Custom Explor Folder from Windows 10/11 only
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations"*.*
rd /s /q "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations"
md "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations"
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ======= 30%%

echo 8) Current Run Command History from Registry files
REG Query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

echo 8) Deleting Run Command History from Registry
REG Query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU
REG Delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU /VA /F
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ======== 35%%

echo 9) Current Run Command History from Registry files
REG Query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths

echo 9) Deleting Path History from File Explorer Registry
REG Delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths /VA /F
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ========= 40%%

echo 10) Current Windows Prefetch Folder files
Tree %windir%\Prefetch /F /A

echo 10) Deleting Windows Prefetch Folder
del C:\Windows\Prefetch*.* /Q
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ========== 45%%

echo 11) Current Windows .bak files
Tree %windir%\Prefetch /F /A

echo 11) Deleting Windows .bak files
del /s /q /f c:*.bak
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait Almost Done...
echo ----------------------------------
echo Progress: =========== 50%%

echo 12) Current Windows Update Download files
Tree %windir%\softwaredistribution /F /A

echo 12) Deleting Current Windows Update Download files
net stop wuauserv
rmdir %windir%\softwaredistribution /s /q
net start wuauserv
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ============ 55%%

echo 13) Current Recyclebin files
Tree c:$Recycle.bin /F /A
Tree d:$Recycle.bin /F /A
Tree e:$Recycle.bin /F /A

echo 13) Deleting Recyclebin Files
del c:$Recycle.bin*.* /f /s /q
del d:$Recycle.bin*.* /f /s /q
del e:$Recycle.bin*.* /f /s /q
call powershell.exe Clear-RecycleBin -force -ErrorAction:Ignore
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait Almost Done...
echo ----------------------------------
echo Progress: ============== 60%%

echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait Almost Done...
echo ----------------------------------
echo Progress: =============== 65%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ================ 70%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ================== 80%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: =================== 85%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ==================== 90%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ===================== 95%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ====================== 100%%
echo ----------------------------------
GOTO END
:END
cls
echo.
echo.
echo Clear Files Successfully complete...
echo ----------------------------------
echo Progress: ====================== 100%%
echo.
echo.
Color 1A

echo ===========================================================================================
echo Last Clear Time: %DATE% %TIME%
echo ===========================================================================================
for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
echo ===========================================================================================%ESC%[1;31m
echo Deleting Temp, Prefetch, Recent, Windows Update Files, Empty Recyclebin, Explor Folder, Run Command, .bak%ESC%[1;32m
echo ===========================================================================================
echo Please Check this Deleting History Log file Where you Run this Command from a Folder
echo ===========================================================================================%ESC%[1;31m
echo Contact me as [email protected] If you need any help..Thanks

echo Do Not Delete This Folder Or It Contents.
echo ====================================================================================================================
echo %windir%\installer

Pause

@Shamim-Ul-Islam-Shihab
Copy link

2

I selected All Files and named it .bat

@devomman

@devomman
Copy link
Author

@echo off

:: (Run as Admin code starts)
REM  Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\icacls.exe" "%SYSTEMROOT%\system32\config\system"

REM If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Now Running As Administrative Privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    pushd "%CD%"
    CD /D "%~dp0"
:: (Run as Admin code ends)
::=======================================
::=======================================


:: (Your code is start from here:)
::===========================>

@echo off
color 1E
Title Clear Command by Omman
echo This delete will stop your update running service and deleting "Update files"
echo Are your sure want to clean and delete files?
Pause
echo.
cls
echo.
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress:  = 1%%
echo =========================================================================================== 
echo Last Clear Time: %DATE% %TIME% 
echo =========================================================================================== 
echo 1) Current Windows Temp Folder files 
Tree %windir%\Temp /F /A 
echo =========================================================================================== 
echo 1) Deleting Windows Temp Folder 
del /s /f /q %windir%\Temp\*.* 
rd /s /q %windir%\Temp 
md %windir%\Temp 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: == 2%%
echo =========================================================================================== 
echo 2) Current Local %Temp% Folder files 
Tree %USERPROFILE%\APPDATA\Local\Temp /F /A 
echo =========================================================================================== 
echo 2) Deleting Local %Temp% Folder 
del /s /f /q %Temp%\*.* 
rd /s /q %Temp% 
md %Temp%\ 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: == 3%%
echo =========================================================================================== 
echo 3) Current Windows Prefetch Folder files 
Tree %windir%\Prefetch /F /A 
echo =========================================================================================== 
echo 3) Deleting Windows Prefetch Folder 
del /s /f /q %windir%\Prefetch\*.* 
rd /s /q %windir%\Prefetch 
md %windir%\Prefetch 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: === 10%%
echo =========================================================================================== 
echo 4) Current User Local Setting Temp Folder files 
Tree %USERPROFILE%\APPDATA\Local\Temp /F /A 
echo =========================================================================================== 
echo 4) Deleting User Local Setting Temp Folder 
del /s /f /q "%USERPROFILE%\Local Settings\Temp"\*.* 
rd /s /q "%USERPROFILE%\Local Settings\Temp" 
md "%USERPROFILE%\Local Settings\Temp" 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ==== 15%%
echo =========================================================================================== 
echo 5) Current Recent Folder from Windows 10/11 only files 
Tree "%APPDATA%\Microsoft\Windows\Recent" /F /A 
echo =========================================================================================== 
echo 5) Deleting Recent Folder from Windows 10/11 only 
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent"\*.* 
rd /s /q "%APPDATA%\Microsoft\Windows\Recent" 
md "%APPDATA%\Microsoft\Windows\Recent" 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ===== 20%%
echo =========================================================================================== 
echo 6) Current Recent Explor Folder from Windows 10/11 only files 
Tree "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations" /F /A 
echo =========================================================================================== 
echo 6) Deleting Recent Explor Folder from Windows 10/11 only 
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations"\*.* 
rd /s /q "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations" 
md "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations" 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ====== 25%%
echo =========================================================================================== 
echo 7) Current Recent Custom Explor Folder from Windows 10/11 only files 
Tree "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations" /F /A 
echo =========================================================================================== 
echo 7) Deleting Recent Custom Explor Folder from Windows 10/11 only 
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations"\*.* 
rd /s /q "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations" 
md "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations" 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ======= 30%%
echo =========================================================================================== 
echo 8) Current Run Command History from Registry files 
REG Query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU 
echo =========================================================================================== 
echo 8) Deleting Run Command History from Registry 
REG Query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU 
REG Delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU /VA /F 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ======== 35%%
echo =========================================================================================== 
echo 9) Current Run Command History from Registry files 
REG Query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths 
echo =========================================================================================== 
echo 9) Deleting Path History from File Explorer Registry 
REG Delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths /VA /F 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ========= 40%%
echo =========================================================================================== 
echo 10) Current Windows Prefetch Folder files 
Tree %windir%\Prefetch /F /A 
echo =========================================================================================== 
echo 10) Deleting Windows Prefetch Folder 
del C:\Windows\Prefetch\*.* /Q 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ========== 45%%
echo =========================================================================================== 
echo 11) Current Windows .bak files 
Tree %windir%\Prefetch /F /A 
echo =========================================================================================== 
echo 11) Deleting Windows .bak files 
del /s /q /f c:\*.bak 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait Almost Done...
echo ----------------------------------
echo Progress: =========== 50%%
echo =========================================================================================== 
echo 12) Current Windows Update Download files 
Tree %windir%\softwaredistribution /F /A 
echo =========================================================================================== 
echo 12) Deleting Current Windows Update Download files 
net stop wuauserv 
rmdir %windir%\softwaredistribution  /s /q 
net start wuauserv 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait...
echo ----------------------------------
echo Progress: ============ 55%%
echo =========================================================================================== 
echo 13) Current Recyclebin files 
Tree c:\$Recycle.bin /F /A 
Tree d:\$Recycle.bin /F /A 
Tree e:\$Recycle.bin /F /A 
echo =========================================================================================== 
echo 13) Deleting Recyclebin Files 
del c:\$Recycle.bin\*.* /f /s /q 
del d:\$Recycle.bin\*.* /f /s /q 
del e:\$Recycle.bin\*.* /f /s /q 
call powershell.exe Clear-RecycleBin -force -ErrorAction:Ignore 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait Almost Done...
echo ----------------------------------
echo Progress: ============== 60%%
echo =========================================================================================== 
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading Please Wait Almost Done...
echo ----------------------------------
echo Progress: =============== 65%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ================ 70%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ================== 80%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: =================== 85%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ==================== 90%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ===================== 95%%
echo ----------------------------------
ping -n 1 localhost >nul
cls
echo.
echo.
echo Loading...
echo ----------------------------------
echo Progress: ====================== 100%%
echo ----------------------------------
GOTO END
:END
cls
echo.
echo.
echo Clear Files Successfully complete...
echo ----------------------------------
echo Progress: ====================== 100%%
echo.
echo.
Color 1A

echo ===========================================================================================
echo Last Clear Time: %DATE% %TIME%
echo ===========================================================================================
for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
echo ===========================================================================================%ESC%[1;31m
echo Deleting Temp, Prefetch, Recent, Windows Update Files, Empty Recyclebin, Explor Folder, Run Command, .bak%ESC%[1;32m
echo ===========================================================================================
echo Please Check this Deleting History Log file Where you Run this Command from a Folder
echo ===========================================================================================%ESC%[1;31m
echo Contact me as [email protected] If you need any help..Thanks


echo Do Not Delete This Folder Or It Contents.
echo ====================================================================================================================
echo %windir%\installer

Pause

@devomman
Copy link
Author

@Shamim-Ul-Islam-Shihab copy this code and create a new notepad file then save as file type all files & file name clear.bat then run as administrator Thanks!

@Shamim-Ul-Islam-Shihab
Copy link

  • Thank you very much brother! Now this is working beautifully!

  • I put the file in the Start Up Folder placement which I clean as soon as I open my laptop!

  • This is actually working a lot for me

NB: I also removed everything like your guidelines, but it didn't happen! Automatic Notepad was becoming and 45% came Automatic 2 Folders Desktop Homepage was leaving!

However, now it works perfectly! Thanks bro

@devomman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment