PC Cleaning, Stage II


My first pc was a windows 95 compaq.

I think it had a 2GB hard drive, 8mb ram.

Fast little bugger for what it was. I was lucky that a family friend knew I loved computers and since my family was quite poor, offered it to me as he was upgrading. I think I received it right when windows 98 was about to release.

He gave me the aol cd and also told me the trick to get constant free access. (by uninstalling and reinstalling it multiple times, deleting a certain file between installs)

I had later got some money doing odd jobs around the neighborhood and eventually upgraded to windows 98 as well as bumping the memory to 32 mb I believe.

Man, that was a wild time for me.....
 

My Computers

System One System Two

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom Built
    CPU
    Ryzen 7 5700 X3D
    Motherboard
    MSI MPG B550 GAMING PLUS
    Memory
    64 GB DDR4 3600mhz Gskill Ripjaws V
    Graphics Card(s)
    RTX 4070 Super , 12GB VRAM Asus EVO Overclock
    Monitor(s) Displays
    Gigabyte M27Q (rev. 2.0) 2560 x 1440 @ 170hz HDR
    Hard Drives
    2TB Samsung nvme ssd
    2TB XPG nvme ssd
    PSU
    CORSAIR RMx SHIFT Series™ RM750x 80 PLUS Gold Fully Modular ATX Power Supply
    Case
    CORSAIR 3500X ARGB Mid-Tower ATX PC Case – Black
    Cooling
    ID-COOLING FROSTFLOW X 240 CPU Water Cooler
    Internet Speed
    900mbps DOWN, 100mbps UP
  • Operating System
    Chrome OS
    Computer type
    Laptop
    Manufacturer/Model
    HP Chromebook
    CPU
    Intel Pentium Quad Core
    Memory
    4GB LPDDR4
    Monitor(s) Displays
    14 Inch HD SVA anti glare micro edge display
    Hard Drives
    64 GB emmc
When I was on my computer, it tied up the phone line. I can remember the weird tones as the modem negotiated a connection. Any program would take hours to download. I think the phone number was a 1-800 number but I paid a subscription for the internet. My dad never complained so I guess it did not show on the phone bill!
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2 26100.2894
    Computer type
    Laptop
    Manufacturer/Model
    Acer Swift SF114-34
    CPU
    Pentium Silver N6000 1.10GHz
    Memory
    4GB
    Screen Resolution
    1920 x 1080
    Hard Drives
    SSD
    Cooling
    fanless
    Internet Speed
    150 Mbps
    Browser
    Brave
    Antivirus
    Webroot Secure Anywhere
    Other Info
    System 3

    ASUS T100TA Transformer
    Processor Intel Atom Z3740 @ 1.33GHz
    Installed RAM 2.00 GB (1.89 GB usable)
    System type 32-bit operating system, x64-based processor

    Edition Windows 10 Home
    Version 22H2 build 19045.3570
  • Operating System
    Windows 11 Pro 23H2 22631.2506
    Computer type
    Laptop
    Manufacturer/Model
    HP Mini 210-1090NR PC (bought in late 2009!)
    CPU
    Atom N450 1.66GHz
    Memory
    2GB
    Browser
    Brave
    Antivirus
    Webroot
Yup! My first PC was 43 years ago and today it wouldn't even be a good doorstop! It had a grand total of 64K of memory and one floppy disk drive. I paid over $5,000 USD for it and I paid another $2,000 for a 5 MB HD!. Yes, that's right, a 5 megabyte, not gigabyte, hard drive!
Gary, you're just another Auld Fahrt, like me.
But that's where we differ. You like to spend money and I don't. You bought your first PC for $5000, and I built my own for just a few hundred.
Then I re-programmed the old Erso BIOS to speed it up, and to display my name on boot up! Loads of run.

I started out with 64 meg of ram, and two Single Sided IBM, Full Height floppy drives and a Seagate ST225, 20 Meg HD.
ST-225 20mb.jpg

That got updated to an ST4038, 30 Meg drive and I thought I was in deep cotton. lol

Retail on that ST4038 was $700. I got three of them, for FREE.
ST-4038 30mb.jpg

On that first PC, I learned how to re-align those old IBM Floppy Drives, something I had done a lot on the Commodore 1541 Disk Drives.
I made a lot of money, re-aligning disk drives for people.

Building that first PC, and learning how to fix it when something went wrong, launched me into the PC business.
I also had to learn DOS. My first copy of DOS 2.0 was given to me by a good friend. Then I learned how to write DOS batch menus, using Ansi Color. I loved doing that.
ME boot from SD.jpg
BOY, it's been years since I've even thought about doing all that stuff.

Seymour, if you want to re-write my Cleanup.bat program, go ahead, but just know that it works perfectly GOOD for me.
And I did write it for me, and my PC's and the programs and browsers that I use. I don't use the Chrome browser, but I added that for those who do. Some day, I may also add Safari. I have a friend who likes that one.

Cheers Y'all!
TM :cool:
 

My Computer

OH, I forgot to mention..... I've always knows that a Windows Registry can get corrupted, and periodic cleaning can fix that.
There used to be a forum where you could get Banned for just mentioning Registry Cleaning. !!!

The worse Registry I ever saw was my own, after I Uninstalled Windows OFFICE 2003 (I think it was)
The Windows Uninstaller seemed to remove the program from my HD just fine.
But then, I decided to try my Registry Cleaner, , , it ran, and ran, and ran, and ran, and when it stopped scanning, it had uncovered 30 megabytes of CRAP related to OFFICE, that the uninstaller had just left behind. Deleting that CRAP, reduced the size of my registry by 1/3.
For years, I ran a tweak that loaded the registry into RAM on boot, for faster operation. So keeping the registry as lean and clean as possible really helped my PC's performance. Doing that really isn't required any more, with the FAST SSD's.

Just like someone will keep the dust off of the Grand Piano, I like to keep the dust out of my registry. :wink:

Cheers Mates!
TM :cool:
PS: I used to do Registry Cleaning for my customers, and often the Cleaner would remove THOUSANDS of dead entries. Greatly reducing the size of their registry, and improving the over all system performance.
 

My Computer

Gary, you're just another Auld Fahrt, like me.
But that's where we differ. You like to spend money and I don't. You bought your first PC for $5000, and I built my own for just a few hundred.
Then I re-programmed the old Erso BIOS to speed it up, and to display my name on boot up! Loads of run.

I started out with 64 meg of ram, and two Single Sided IBM, Full Height floppy drives and a Seagate ST225, 20 Meg HD.
View attachment 105614

That got updated to an ST4038, 30 Meg drive and I thought I was in deep cotton. lol

Retail on that ST4038 was $700. I got three of them, for FREE.
View attachment 105615

On that first PC, I learned how to re-align those old IBM Floppy Drives, something I had done a lot on the Commodore 1541 Disk Drives.
I made a lot of money, re-aligning disk drives for people.

Building that first PC, and learning how to fix it when something went wrong, launched me into the PC business.
I also had to learn DOS. My first copy of DOS 2.0 was given to me by a good friend. Then I learned how to write DOS batch menus, using Ansi Color. I loved doing that.
View attachment 105616
BOY, it's been years since I've even thought about doing all that stuff.

Seymour, if you want to re-write my Cleanup.bat program, go ahead, but just know that it works perfectly GOOD for me.
And I did write it for me, and my PC's and the programs and browsers that I use. I don't use the Chrome browser, but I added that for those who do. Some day, I may also add Safari. I have a friend who likes that one.

Cheers Y'all!
TM :cool:
We launched ourselves into the PC business in quite different ways. Instead of going the hardware fixing and repair route as you did, I spent the first year with my new IBM PC working day and night to learn programming. At the end of that year, I passed the interviews to become a software engineer at a major corporation. Over the years I wrote the software for their internal telephone system and their customer support system among many other projects. I did well enough to take early retirement some 20 years ago and become my own boss trading stocks.
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Dell XPS 16 9640
    CPU
    Intel Core Ultra 9 185H
    Memory
    32GB LPDDR5x 7467 MT/s
    Graphics Card(s)
    NVIDIA GeForce RTX 4070 8GB GDDR6
    Monitor(s) Displays
    16.3 inch 4K+ OLED Infinity Edge Touch
    Screen Resolution
    3840 x 2400
    Hard Drives
    1 Terabyte M.2 PCIe NVMe SSD
    Cooling
    Vapor Chamber Cooling
    Mouse
    None
    Internet Speed
    960 Mbps Netgear Mesh + 2 Satellites
    Browser
    Microsoft Edge (Chromium) + Bing
    Antivirus
    Microsoft Windows Security (Defender)
    Other Info
    Microsoft 365 subscription
    Microsoft OneDrive 1TB Cloud
    Microsoft Visual Studio
    Microsoft Visual Studio Code
    Microsoft PowerToys
    Macrium Reflect X subscription
    Dell Support Assist
    Dell Command | Update
    1Password Password Manager
    Amazon Kindle for PC
    Interactive Brokers Trader Workstation
    Lightroom/Photoshop subscription
    BitLocker
    CoPilot
Yeah, I too miss some of the old Utilities that stopped working after XP. But, most have been replaced by newer, faster and betterer Utils that do a good job. I keep "WinUtils" installed on all my PC's , mainly for the registry cleaner, although it has many other very usable features.

But since most of those packaged programs don't get all the junk that I want to get rid of. . . I've written my own Cleanup.bat program.

I'll post the text of that batch file here, for anyone who wants to use it.

Just Copy and Paste the text into any word processor, and then save it as "Cleanup.bat".

(this version is set to clean out the Temporary Internet Files, from Edge, Chrome, Waterfox and Firefox.)

@Echo off
cls
Rem: Count the number of files on "C" before the cleanup.
Echo: Performing initial file count. Please wait!
for /f "delims=" %%A in ( ' dir /a /s "C:\" ^| find /c /v "" ' ) do set Count1=%%A
Echo: Disk Cleanup now starting. Please Wait!
Del /F /S /Q C:\*.tmp
Del /F /S /Q C:\*.old
Del /F /S /Q C:\*.log
Del /F /S /Q C:\*.bak

PowerShell rm C:\Users\%UserName%\AppData\Local\Temp\* -Recurse -ErrorAction:Ignore
Del /F /S /Q "C:\Users\Admin\AppData\Local\Temp\*.*"

Echo: Deleting Waterfox Temporary Internet Files
::TAKEOWN /F "C:\Users\%UserName%\AppData\Local\Waterfox\Profiles\e7g81fpe.default-release\cache2\*.*"
Del /F /S /Q "C:\Users\%UserName%\AppData\Local\Waterfox\Profiles\e7g81fpe.default-release\cache2\*.*"

Echo: Deleting Chrome Temporary Internet Files
Del /F /S /Q "C:\Users\%UserName%\AppData\Local\Google\Chrome\User Data\Default\Cache\*.*"

Echo Del Firefox Temporary Internet Files
del /F /S /Q "C:\Users\%UserName%\AppData\Local\Mozilla\Firefox\Profiles\*.*"

Echo Del Edge Temporary Internet Files
del /F /S /Q "C:\Users\%UserName%\AppData\Local\Microsoft\Edge\User Data\Default\Cache\*.*"
Echo:
Echo:
TAKEOWN /F "C:\Windows\Prefetch"
del /F /S /Q "C:\Windows\Prefetch\*.*"
Echo:
Echo:
del /F /S /Q "C:\Documents and Settings\Default User\Local Settings\Temp\*.*"
del /F /S /Q "C:\Documents and Settings\Default User\Local Settings\Temporary Internet Files\*.*"
del /F /S /Q "C:\Documents and Settings\Default User\Local Settings\History\History\*.*"
del /F /S /Q "C:\Documents and Settings\%Username%\Local Settings\Temporary Internet Files\*.*"
del /F /S /Q "C:\Documents and Settings\%Username%\Local Settings\Temp\*.*"
Echo Now deleting Recycle Bin
Echo:
PowerShell Clear-RecycleBin -force -ErrorAction:Ignore

Echo: All Recycle Bins Emptied

del /F /S /Q "C:\Users\%UserName%"\AppData\Local\temp\*.*"

Echo:
Echo:

Echo: Disk Cleanup is now complete.
Rem: Show number of files left on HD after the cleanup.
Echo: Performing File Count, After Cleaning. Please Wait!
for /f "delims=" %%A in ( ' dir /a /s "C:\" ^| find /c /v "" ' ) do set Count2=%%A
set /a deleted=%Count1% - %Count2%
Echo:
Echo: File Count before cleaning: %Count1% files
Echo:
Echo: File count after cleaning: %Count2% files
Echo:
Echo: Files deleted: %deleted% files

Echo:
Echo: The Date Is: %Date%
Echo:
Echo: The Time Is: %Time%
Echo:
Echo:
pause
Revised .bat file to work on all windows computers.

**START**
start copying below)

@Echo off
cls

Rem: Count the number of files on "C:" before the cleanup.
Echo: Performing initial file count. Please wait!
for /f "delims=" %%A in ('dir /a /s "C:\" ^| find /c /v ""') do set Count1=%%A

Echo: Disk Cleanup now starting. Please wait!

Rem: Delete various types of temporary files
Del /F /S /Q C:\*.tmp
Del /F /S /Q C:\*.old
Del /F /S /Q C:\*.log
Del /F /S /Q C:\*.bak

Rem: Cleanup user temp directories
PowerShell -Command "Remove-Item -Path $env:TEMP\* -Recurse -Force -ErrorAction SilentlyContinue"
PowerShell -Command "Remove-Item -Path 'C:\Users\Public\AppData\Local\Temp\*' -Recurse -Force -ErrorAction SilentlyContinue"

Rem: Delete browser temporary internet files
for /D %%D in ("%LOCALAPPDATA%\*") do (
if exist "%%D\Cache\" Del /F /S /Q "%%D\Cache\*.*"
if exist "%%D\Temp\" Del /F /S /Q "%%D\Temp\*.*"
)

Rem: Cleanup Prefetch directory
Echo: Cleaning up Prefetch directory
TAKEOWN /F "C:\Windows\Prefetch" /R /D Y
ICACLS "C:\Windows\Prefetch" /T /grant:r everyone:F
Del /F /S /Q "C:\Windows\Prefetch\*.*"

Rem: Cleanup Recycle Bin
Echo: Emptying Recycle Bin
PowerShell -Command "Clear-RecycleBin -Force -ErrorAction SilentlyContinue"

Rem: Cleanup other possible temporary directories
for /D %%D in ("C:\Documents and Settings\*") do (
if exist "%%D\Local Settings\Temp\" Del /F /S /Q "%%D\Local Settings\Temp\*.*"
if exist "%%D\Local Settings\Temporary Internet Files\" Del /F /S /Q "%%D\Local Settings\Temporary Internet Files\*.*"
if exist "%%D\Local Settings\History\History\" Del /F /S /Q "%%D\Local Settings\History\History\*.*"
)

Echo: Performing file count after cleaning. Please wait!
for /f "delims=" %%A in ('dir /a /s "C:\" ^| find /c /v ""') do set Count2=%%A

set /a deleted=%Count1% - %Count2%
Echo: File Count before cleaning: %Count1% files
Echo: File Count after cleaning: %Count2% files
Echo: Files deleted: %deleted% files

Echo: The Date Is: %Date%
Echo: The Time Is: %Time%

pause
(stop here)
**STOP**
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    xidax.com
    CPU
    Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
    Motherboard
    GIGABYTE GA-Z270P-D3
    Memory
    DDR4-2400 32.0 GB
    Graphics Card(s)
    Nvidia Geforce GTX 1070 8GB
    Sound Card
    Realtek(R) Audio Driver 6.0.8703.1
    Monitor(s) Displays
    DELL S2721NX
    Screen Resolution
    1920x1080
    Internet Speed
    1Gig
%UserProfile%
Yeah, I too miss some of the old Utilities that stopped working after XP. But, most have been replaced by newer, faster and betterer Utils that do a good job. I keep "WinUtils" installed on all my PC's , mainly for the registry cleaner, although it has many other very usable features.

But since most of those packaged programs don't get all the junk that I want to get rid of. . . I've written my own Cleanup.bat program.

I'll post the text of that batch file here, for anyone who wants to use it.

Just Copy and Paste the text into any word processor, and then save it as "Cleanup.bat".

(this version is set to clean out the Temporary Internet Files, from Edge, Chrome, Waterfox and Firefox.)

@Echo off
cls
Rem: Count the number of files on "C" before the cleanup.
Echo: Performing initial file count. Please wait!
for /f "delims=" %%A in ( ' dir /a /s "C:\" ^| find /c /v "" ' ) do set Count1=%%A
Echo: Disk Cleanup now starting. Please Wait!
Del /F /S /Q C:\*.tmp
Del /F /S /Q C:\*.old
Del /F /S /Q C:\*.log
Del /F /S /Q C:\*.bak

PowerShell rm C:\Users\%UserName%\AppData\Local\Temp\* -Recurse -ErrorAction:Ignore
Del /F /S /Q "C:\Users\Admin\AppData\Local\Temp\*.*"

Echo: Deleting Waterfox Temporary Internet Files
::TAKEOWN /F "C:\Users\%UserName%\AppData\Local\Waterfox\Profiles\e7g81fpe.default-release\cache2\*.*"
Del /F /S /Q "C:\Users\%UserName%\AppData\Local\Waterfox\Profiles\e7g81fpe.default-release\cache2\*.*"

Echo: Deleting Chrome Temporary Internet Files
Del /F /S /Q "C:\Users\%UserName%\AppData\Local\Google\Chrome\User Data\Default\Cache\*.*"

Echo Del Firefox Temporary Internet Files
del /F /S /Q "C:\Users\%UserName%\AppData\Local\Mozilla\Firefox\Profiles\*.*"

Echo Del Edge Temporary Internet Files
del /F /S /Q "C:\Users\%UserName%\AppData\Local\Microsoft\Edge\User Data\Default\Cache\*.*"
Echo:
Echo:
TAKEOWN /F "C:\Windows\Prefetch"
del /F /S /Q "C:\Windows\Prefetch\*.*"
Echo:
Echo:
del /F /S /Q "C:\Documents and Settings\Default User\Local Settings\Temp\*.*"
del /F /S /Q "C:\Documents and Settings\Default User\Local Settings\Temporary Internet Files\*.*"
del /F /S /Q "C:\Documents and Settings\Default User\Local Settings\History\History\*.*"
del /F /S /Q "C:\Documents and Settings\%Username%\Local Settings\Temporary Internet Files\*.*"
del /F /S /Q "C:\Documents and Settings\%Username%\Local Settings\Temp\*.*"
Echo Now deleting Recycle Bin
Echo:
PowerShell Clear-RecycleBin -force -ErrorAction:Ignore

Echo: All Recycle Bins Emptied

del /F /S /Q "C:\Users\%UserName%"\AppData\Local\temp\*.*"

Echo:
Echo:

Echo: Disk Cleanup is now complete.
Rem: Show number of files left on HD after the cleanup.
Echo: Performing File Count, After Cleaning. Please Wait!
for /f "delims=" %%A in ( ' dir /a /s "C:\" ^| find /c /v "" ' ) do set Count2=%%A
set /a deleted=%Count1% - %Count2%
Echo:
Echo: File Count before cleaning: %Count1% files
Echo:
Echo: File count after cleaning: %Count2% files
Echo:
Echo: Files deleted: %deleted% files

Echo:
Echo: The Date Is: %Date%
Echo:
Echo: The Time Is: %Time%
Echo:
Echo:
pause
Try this script. It's organized and redundant and old code removed. Must run as Administrator.

@echo off
setlocal

:: Check for administrative privileges
echo Checking for administrative privileges...
net session >nul 2>&1
if %errorlevel% neq 0 (
echo This script requires administrative privileges. Please run as Administrator.
pause
exit /b
)

:: Clear screen
cls

:: Perform initial file count on "C:" drive
echo Performing initial file count. Please wait...
for /f "delims=" %%A in ('dir /a /s "C:\" ^| find /c /v ""') do set "Count1=%%A"

:: Start cleanup process
echo Disk Cleanup now starting. Please wait!

:: Delete common temporary files
echo Deleting common temporary files...
del /f /s /q "C:\*.tmp" >nul 2>&1
del /f /s /q "C:\*.old" >nul 2>&1
del /f /s /q "C:\*.log" >nul 2>&1
del /f /s /q "C:\*.bak" >nul 2>&1

:: Cleanup user-specific temporary files
echo Deleting user-specific temporary files...
PowerShell -Command "Remove-Item -Path '%Temp%\*' -Recurse -Force -ErrorAction SilentlyContinue" >nul 2>&1
PowerShell -Command "Remove-Item -Path '%LocalAppData%\Temp\*' -Recurse -Force -ErrorAction SilentlyContinue" >nul 2>&1

:: Cleanup browser caches
echo Deleting browser temporary files...
for %%B in (
"Waterfox\Profiles\*\cache2"
"Google\Chrome\User Data\Default\Cache"
"Mozilla\Firefox\Profiles\*\cache2"
"Microsoft\Edge\User Data\Default\Cache"
) do (
if exist "%LocalAppData%\%%B" (
del /f /s /q "%LocalAppData%\%%B\*.*" >nul 2>&1
)
)

:: Cleanup Windows Prefetch
echo Deleting Windows Prefetch files...
takeown /f "C:\Windows\Prefetch" /r /d y >nul 2>&1
del /f /s /q "C:\Windows\Prefetch\*.*" >nul 2>&1

:: Clear Recycle Bin
echo Emptying Recycle Bin...
PowerShell -Command "Clear-RecycleBin -Confirm:$false -ErrorAction SilentlyContinue" >nul 2>&1

:: Perform file count after cleanup
echo Performing file count after cleaning. Please wait...
for /f "delims=" %%A in ('dir /a /s "C:\" ^| find /c /v ""') do set "Count2=%%A"

:: Calculate and display file count results
set /a Deleted=%Count1% - %Count2%
echo.
echo File Count before cleaning: %Count1% files
echo File Count after cleaning: %Count2% files
echo Files deleted: %Deleted% files

:: Display date and time
echo.
echo The Date Is: %Date%
echo The Time Is: %Time%
echo.

pause
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    xidax.com
    CPU
    Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
    Motherboard
    GIGABYTE GA-Z270P-D3
    Memory
    DDR4-2400 32.0 GB
    Graphics Card(s)
    Nvidia Geforce GTX 1070 8GB
    Sound Card
    Realtek(R) Audio Driver 6.0.8703.1
    Monitor(s) Displays
    DELL S2721NX
    Screen Resolution
    1920x1080
    Internet Speed
    1Gig
**This new clean.bat script will work on Windows 7, 8, 10, and 11

@Echo off
cls
setlocal

:: Define common paths
set "TEMP_DIR=%UserProfile%\AppData\Local\Temp"
set "CHROME_CACHE=%LocalAppData%\Google\Chrome\User Data\Default\Cache"
set "FIREFOX_CACHE=%LocalAppData%\Mozilla\Firefox\Profiles"
set "EDGE_CACHE=%LocalAppData%\Microsoft\Edge\User Data\Default\Cache"
set "THORIUM_CACHE=%LocalAppData%\Thorium\User Data\Default\Cache"
set "THORIUM_COOKIES=%LocalAppData%\Thorium\User Data\Default\Cookies"
set "PREFETCH_DIR=C:\Windows\Prefetch"
set "WIN_UPDATE_DIR=C:\Windows\SoftwareDistribution\Download"
set "ERROR_REPORT_DIR=C:\ProgramData\Microsoft\Windows\WER\ReportArchive"
set "WIN_INSTALLER_CACHE=C:\Windows\Installer\$PatchCache$"
set "DEFENDER_CACHE=C:\ProgramData\Microsoft\Windows Defender\Scans\History"
set "EVENT_LOGS_DIR=C:\Windows\System32\winevt\Logs"

:: Define file patterns to delete
set "FILE_PATTERNS=*.tmp *.old *.log *.bak"

:: Define all directories for cleanup
set "DIRS=%TEMP_DIR% %CHROME_CACHE% %FIREFOX_CACHE% %EDGE_CACHE% %THORIUM_CACHE% %THORIUM_COOKIES% %PREFETCH_DIR% %WIN_UPDATE_DIR% %ERROR_REPORT_DIR% %WIN_INSTALLER_CACHE% %DEFENDER_CACHE% %EVENT_LOGS_DIR%"

:: Count files on "C:" before cleanup
Echo Performing initial file count. Please wait...
for /f "delims=" %%A in ('dir /a /s /b "C:\" ^| find /c /v ""') do set Count1=%%A

:: Disk Cleanup
Echo Disk Cleanup now starting. Please wait...
PowerShell -Command "& {
$dirs = @('%TEMP_DIR%', '%CHROME_CACHE%', '%FIREFOX_CACHE%', '%EDGE_CACHE%', '%THORIUM_CACHE%', '%THORIUM_COOKIES%', '%PREFETCH_DIR%', '%WIN_UPDATE_DIR%', '%ERROR_REPORT_DIR%', '%WIN_INSTALLER_CACHE%', '%DEFENDER_CACHE%', '%EVENT_LOGS_DIR%')
$patterns = @($env:FILE_PATTERNS -split ' ')

# Delete common temporary file types
$patterns | ForEach-Object { Remove-Item -Path "C:\$_" -Recurse -Force -ErrorAction SilentlyContinue }

# Delete files from defined directories
$dirs | ForEach-Object {
if (Test-Path $_) {
Remove-Item -Path "$_\*.*" -Recurse -Force -ErrorAction SilentlyContinue
}
}

# Delete Prefetch files and old event logs
Remove-Item -Path "$env:PREFETCH_DIR\*" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$env:EVENT_LOGS_DIR\*" -Recurse -Force -ErrorAction SilentlyContinue

# Optional: Delete System Restore Points
Disable-ComputerRestore -Drive 'C:' -ErrorAction SilentlyContinue
Enable-ComputerRestore -Drive 'C:' -ErrorAction SilentlyContinue

# Clear Recycle Bin
Clear-RecycleBin -Force -ErrorAction SilentlyContinue
}"

:: Perform final file count
Echo Performing file count after cleaning. Please wait...
for /f "delims=" %%A in ('dir /a /s /b "C:\" ^| find /c /v ""') do set Count2=%%A
set /a deleted=%Count1% - %Count2%

:: Display results
Echo File count before cleaning: %Count1% files
Echo File count after cleaning: %Count2% files
Echo Files deleted: %deleted% files
Echo The Date Is: %Date%
Echo The Time Is: %Time%

pause
endlocal



**Enjoy! Please modify and share if you'd like to make it even better**
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    xidax.com
    CPU
    Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
    Motherboard
    GIGABYTE GA-Z270P-D3
    Memory
    DDR4-2400 32.0 GB
    Graphics Card(s)
    Nvidia Geforce GTX 1070 8GB
    Sound Card
    Realtek(R) Audio Driver 6.0.8703.1
    Monitor(s) Displays
    DELL S2721NX
    Screen Resolution
    1920x1080
    Internet Speed
    1Gig
**This new clean.bat script will work on Windows 7, 8, 10, and 11
When it finishes is it supposed to just close? That's what happened when I ran it as Admin.
 

My Computers

System One System Two

  • OS
    Windows 11 Canary Channel
    Computer type
    PC/Desktop
    Manufacturer/Model
    PowerSpec B746
    CPU
    Intel Core i7-10700K
    Motherboard
    ASRock Z490 Phantom Gaming 4/ax
    Memory
    16GB (8GB PC4-19200 DDR4 SDRAM x2)
    Graphics Card(s)
    NVIDIA GeForce GTX 1050 TI
    Sound Card
    Realtek Audio
    Monitor(s) Displays
    Samsung SAM0A87 Samsung SAM0D32
    Screen Resolution
    1920 x 1080
    Hard Drives
    NVMe WDC WDS100T2B0C-00PXH0 1TB
    Samsung SSD 860 EVO 1TB
    PSU
    750 Watts (62.5A)
    Case
    PowerSpec/Lian Li ATX 205
    Keyboard
    Logitech K270
    Mouse
    Logitech M185
    Browser
    Microsoft Edge and Firefox
    Antivirus
    ESET Internet Security
  • Operating System
    Windows 11 Canary Channel
    Computer type
    PC/Desktop
    Manufacturer/Model
    PowerSpec G156
    CPU
    Intel Core i5-8400 CPU @ 2.80GHz
    Motherboard
    AsusTeK Prime B360M-S
    Memory
    16 MB DDR 4-2666
    Monitor(s) Displays
    23" Speptre HDMI 75Hz
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 970 EVO 500GB NVMe
    Mouse
    Logitek M185
    Keyboard
    Logitek K270
    Browser
    Firefox, Edge and Edge Canary
    Antivirus
    Windows Defender
@thepcformula

You're making things harder on yourself, checking for the \Users folder or Docs&Settings. The last time the latter was used as a "real" folder was XP. And you're tacking on the user name to the end of whichever path you choose. The user's name does not always match their profile folder, e.g., if the account has been renamed but not the folder. Just use %USERPROFILE% for the profile folder and avoid the whole mess.

Similarly, you're defining variables for local and roaming AppData, along with the user's temp folder, when there are already %LOCALAPPDATA%, %APPDATA%, and %TEMP%, respectively. The variables already exist, and those folders may not be where you're expecting them to be. Usually they are, but not always.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
Back
Top Bottom