Solved Empty Recycle bin from Batch file?


TechnoMage2021

Retired PC Builder/Tech
Power User
VIP
Local time
5:14 AM
Posts
1,041
Location
Central Florida, USA
OS
Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
I know that this may seem frivolous, but I'm dead serious.
Years ago, I wrote a batch file to clean up Windows XP, and it included cleaning out the Recycle Bin.
It's like a lifetime later and I'm trying to do the same thing with a batch file to clean up Win-11.
It runs exactly like I want it to, till I get down to the line to clean out the Recycle Bin.

I Googled the problem and found several so called solutions, except that none of them work.
So I'm looking for a Batch File master, that can help me overcome this problem.
The solution has to work from within the batch file, with no outside help.

PS: I have several programs including windows cleanup that can empty the Recycle bin, but I can save a lot of time if I can just do it from within my Cleanup batch file. Then I could also share my batch file with others.
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
Hello mate, :alien:

You might test option six below to see if the command in it may for work with your BAT file.

 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    HP Spectre x360 2in1 14-eu0098nr (2024)
    CPU
    Intel Core Ultra 7 155H 4.8 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Graphics card(s)
    Integrated Intel Arc
    Sound Card
    Poly Studio
    Monitor(s) Displays
    14" 2.8K OLED multitouch
    Screen Resolution
    2880 x 1800
    Hard Drives
    2 TB PCIe NVMe M.2 SSD
    Internet Speed
    Intel Wi-Fi 7 BE200 (2x2) and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender and Malwarebytes Premium
I am not the OP, but I just tried option #6 in a batch file and it works! Nice! Thanks!
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Apple MacBook Pro 16" 2021
    CPU
    Apple M1 Max 10 core/4 CPU assigned to Parallels 17 VM
    Motherboard
    Apple Silicon M1 Max
    Memory
    64GB/24GB assigned to Parallels 17 VM
    Graphics Card(s)
    Apple 32 core GPU
    Sound Card
    Apple
    Monitor(s) Displays
    16.2" Liquid Retina XDR
    Screen Resolution
    3456-by-2234 native resolution at 254 psi
    Hard Drives
    4TB SSD
    PSU
    Apple
    Case
    Apple
    Cooling
    Apple
    Keyboard
    Apple
    Mouse
    N/A; Apple Trackpad
    Internet Speed
    1.2Gb/42Gb
    Browser
    Parallels 17 VM: MS Edge
    Antivirus
    Parallels 17 VM: MS Defender
I am not the OP, but I just tried option #6 in a batch file and it works! Nice! Thanks!
And I finally got my Recycle Bin icon back on my desktop! After trying to help someone who wanted to delete the RB icon! I figured out how to delete, but it wouldn't restore after deleting it. :(
 

My Computers

System One System Two

  • OS
    Windows 11 23H2 22631.2861
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Envy TE01-1xxx
    CPU
    Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz 2.90 GHz
    Motherboard
    16.0GB Dual-Channel Unknown @ 1463MHz (21-21-21-47)
    Memory
    16384 MBytes
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    Realtek High Definition Audio
    Monitor(s) Displays
    Monitor 1 - Acer 27" Monitor 2 - Acer 27"
    Screen Resolution
    1920 x 1080
    Hard Drives
    WDC PC SN530 SDBPNPZ-512G-1006 (SSD)
    Seagate ST1000DM003-1SB102
    Seagate BUP Slim SCSI Disk Device (SSD)
    PSU
    HP
    Case
    HP
    Cooling
    Standard
    Keyboard
    Logitech Wave K350
    Mouse
    Logitech M705
    Internet Speed
    500 mbps
    Browser
    Firefox
    Antivirus
    Windows Defender
    Other Info
    That's all Folks!
  • Operating System
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
    CPU
    Intel Core i7 (10th gen) 10700
    Motherboard
    Intel
    Memory
    16 GB
    Graphics card(s)
    Intel UHD Graphics 630
    Sound Card
    Built-in
    Monitor(s) Displays
    Acer 27" & Samsung 24"
    Screen Resolution
    1920 x
    Hard Drives
    SSD (512 GB)
    HDD (1 TB)
    Seagate
    PSU
    Intel i7 10th Generation
    Case
    HP
    Cooling
    HP/Intel?
    Mouse
    Logitech M705
    Keyboard
    Logitech Wave K350
    Internet Speed
    50 mbps
    Browser
    Firefox 90.2
    Antivirus
    Windows Defender
    Other Info
    Headphone/Microphone Combo
    SuperSpeed USB Type-A (4 on front)
    HP 3-in-One Card Readr
    SuperSpeed USB Type-C
    DVD Writer
NirSoft does an "emptybin" shortcut for the desktop, too
 

My Computers

System One System Two

  • OS
    Windows 11 22H2 (latest update ... forever anal)
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Slim S01
    CPU
    Intel i5-9400
    Memory
    8GB
    Graphics Card(s)
    NVIDIA GeForce GT730
    Sound Card
    OOBE
    Monitor(s) Displays
    Acer 32"
    Screen Resolution
    1920x1080
    Hard Drives
    2 x 1TB SSDs
    PSU
    OOBE
    Case
    OOBE
    Cooling
    OOBE
    Keyboard
    Logitech wireless
    Mouse
    Logitech wireless
    Internet Speed
    Classic Australian w.a.p.
    Browser
    Brave
    Antivirus
    KIS
  • Operating System
    Windows 11 Pro (latest upadte ... anally always)
    Computer type
    Laptop
    Manufacturer/Model
    HP Pavillion 15
    CPU
    i7-1165G7 @ 2.80GHz
    Graphics card(s)
    Intel Iris Xe Graphics
    Hard Drives
    Samsung NVMe 512GB
    + numerous/multiple SSD Type C USB enclosures
    Internet Speed
    NBN FTTN 50
    Browser
    Brave
    Antivirus
    KIS
Anyone can delete the contents of the Recycle Bin, manually, from the Desktop, and there are programs that can do it to.
But the problem was/is getting the Recycle Bin emptied from within a Batch File, that can be shared, circulated or even posted.

Thank you Shawn, the command you gave me worked!
I can only assume that it worked, because the "Power Shell" is active in Win-11. Without it, every attempt I made, failed.

But the bottom line is, that I now can finish off my Win11Clean.bat program, and move on to the next challenge.

Cheers Mates,
TM :cool:
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
:shawn:
 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    HP Spectre x360 2in1 14-eu0098nr (2024)
    CPU
    Intel Core Ultra 7 155H 4.8 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Graphics card(s)
    Integrated Intel Arc
    Sound Card
    Poly Studio
    Monitor(s) Displays
    14" 2.8K OLED multitouch
    Screen Resolution
    2880 x 1800
    Hard Drives
    2 TB PCIe NVMe M.2 SSD
    Internet Speed
    Intel Wi-Fi 7 BE200 (2x2) and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender and Malwarebytes Premium
Addendum:

One little Trick I use in my batch file is, that I first count the number of files in C:, and then do the cleanup, then count the files again and post the difference, which is the number of files deleted.
That final count looks like this:
Final Count.jpg

And, that's on my PC where I've been testing my Cleanup batch file, for days. It's staggering how fast garbage files can and DO build up on a typical HD.*
One last change, to make this a more universal Cleanup Batch file, in any line that has my actual name in it, I'll have to replace my name with %USERNAME%. Then, I can share this batch file with other Win-11 users.

* I tested this batch file on another one of my PC's running Win-11 and the final count of files deleted was over 3000.
That was a recent install with practically no use.

Thanks again for the Assistance.
TM :cool:
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
One little problem I had to solve today, was that some of the lines in my Batch file would only work if run in Administrator Mode.
That was solved by putting the batch file in its own folder on the HD, and running it from a shortcut on the Desktop. The shortcut, of course, is set to "Run in Administrator Mode".
This evening, I ran the completed Batch File here on my computer where I've been testing it every day for the past several days, and the bottom line was "1186" files removed.
It would be a real Hoot, to run my little Cleanup Batch File on a Win-11 PC that's never had any maintenance at all.
The number of junk files removed could number into the hundreds of thousands.
I wrote a similar Cleanup batch file for Windows XP. It was a real success, and was a great help to me, when cleaning up Customer's PC's.

Cheers Mates!
TM :cool:
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
Windows 11 has this option, no 3rd party tools required. It's perhaps the simplest way to configure retention.
  1. Press Win+I to open Options, search for Storage Sense
  2. Optionally, check Keep Windows running smoothly etc. This will purge files in the %TEMP% directory.
  3. Flip the rocker under Automatic User content cleanup to On.
  4. Set Run Storage Sense to Every Day.
  5. Select Delete files in my recycle bin [...] older than and choose your preference. I have 7 days, YMMV.
  6. Delete files in my Download folder [...] older than is up to you, I don't.
  7. If you're using OneDrive, you may also want to enable Content will become online-only after time. I have set it to 30 days, but this is entirely safe to remove locally cached OneDrive files ASAP. Your choice, again.
Under the hood, Windows activates the Storage Sense task to run on the specified schedule.

Another used space control option is automatic Store Apps archival. App data is retained, but the app itself is uninstalled, and automatically pulled from the Store when you attempt to use it.
  1. In the Options app, search for Archive Apps
  2. This lands you at the Apps > Advanced Apps Settings page. Select Archive Apps on the page.
  3. Flip the only rocker on that page to On.
All of these settings are configurable with a GPO, and thus easy to transfer to other standalone machines even outside of the domain environment, if you have a Professional ed. It's not in the Home ed., tho.
 

My Computers

System One System Two

  • OS
    Windows 11 22621.963
    Computer type
    Laptop
    Manufacturer/Model
    HP Spectre x360, 2021 model, customized.
    CPU
    i7 11th gen
    Motherboard
    OEM
    Memory
    32GB
    Graphics Card(s)
    Iris Xe on Soc + NVIDIA 3050 discrete
    Sound Card
    Realtek?
    Monitor(s) Displays
    16" 4k OLED panel w/touch and pen
    Screen Resolution
    3840×2400
    Hard Drives
    Hynix NVMe 1TB
    PSU
    OEM
    Case
    OEM
    Cooling
    OEM
    Keyboard
    OEM
    Mouse
    OEM Touchpad; Logi Ergo Trackball BT
    Internet Speed
    Cable, 300/10 Mbps
    Browser
    FF, Edge, Chrome
    Antivirus
    Windows Defender
    Other Info
    NVIDIA mostly reserved CUDA development; main graphic is the Xe.
  • Operating System
    Windows 11 22621.963
    Computer type
    PC/Desktop
    Manufacturer/Model
    Quiet PC Ltd., UK. Bespoke.
    CPU
    Intel i7 12th gen
    Motherboard
    ASUS Prime Z-690D P4
    Memory
    128 GB
    Graphics card(s)
    Intel Xe on-Soc + NVIDIA 3070 Ti @ PCIe x16
    Sound Card
    Realtek, on-board
    Monitor(s) Displays
    LG UltraFine 5K 220 ppi on Thunderbolt ext bus
    Screen Resolution
    5120x2880
    Hard Drives
    NVMe Samsung SSD 980 PRO 1TB (SoC x4 PCIe)
    2× NVMe Samsung SSD 980 EVO Plus 2TB (PCH x4 PCIe each)
    PSU
    800W, +35% headroom to requrements.
    Case
    be Quiet!, the most basic one
    Cooling
    Noctua CPU cooler and case fans, to TDP/airflow spec
    Mouse
    Logi Ergo Trackball, BT
    Keyboard
    Present
    Internet Speed
    Cable, 300/10 Mbps
    Browser
    FF, Edge
    Antivirus
    Windows Defender
    Other Info
    Main workstation.
    Display is on the Xe; NVIDIA dedicated to CUDA compute only.
    Guest Debian Hyper-V VM, required for xplat work.
    Add-on PCIe cards:
    * ASUS, Intel AX201 Wireless @5GHz (home Ethernet wiring deteriorated).
    * ASUS Thunderbold EX 4, for display only.
Thank you, for that information.
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
  1. Select Delete files in my recycle bin [...] older than and choose your preference. I have 7 days, YMMV.
This whole procedure was immensely useful, thank you @Cy_kkm - I didn't know it existed! One thing I noticed - deleting files in Recycle and Downloads did not have a 7 day option, does yours actually? I would prefer 7 days, 1 day is too quick and I run some tasks that dump a lot of files into Recycle so 14 days is a little long but ok for me. 7 days would be perfect!
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Apple MacBook Pro 16" 2021
    CPU
    Apple M1 Max 10 core/4 CPU assigned to Parallels 17 VM
    Motherboard
    Apple Silicon M1 Max
    Memory
    64GB/24GB assigned to Parallels 17 VM
    Graphics Card(s)
    Apple 32 core GPU
    Sound Card
    Apple
    Monitor(s) Displays
    16.2" Liquid Retina XDR
    Screen Resolution
    3456-by-2234 native resolution at 254 psi
    Hard Drives
    4TB SSD
    PSU
    Apple
    Case
    Apple
    Cooling
    Apple
    Keyboard
    Apple
    Mouse
    N/A; Apple Trackpad
    Internet Speed
    1.2Gb/42Gb
    Browser
    Parallels 17 VM: MS Edge
    Antivirus
    Parallels 17 VM: MS Defender
One thing I noticed - deleting files in Recycle and Downloads did not have a 7 day option, does yours actually? I would prefer 7 days, 1 day is too quick and I run some tasks that dump a lot of files into Recycle so 14 days is a little long but ok for me. 7 days would be perfect!
I'm applying these options using a GPO, so I can apply the subset of common settings that I always use use to every machine. You just set the number of days there. The caveat is, GPO is unavailable in the Home edition. It might still be settable directly in the registry—this is what the Group Policy Object does when applied. Google for the exact policy name, some tables list the registry keys (whether the Home Ed. pays any attention to these settings, I dunno but vaguely remember it does).

If you apply a GPO, the controls on the corresponding page in Options will be greyed out, and there will be a message “some settings are managed by your organization”—the GPO is a domain thing, this is how admins apply settings to all computers in a domain. Just don't be startled by this.

This template is under Computer/Administrative Templates/System/Storage Sense (the path is not on the screenshot).

storagesense.png


ADDED: There ya go!

 
Last edited:

My Computers

System One System Two

  • OS
    Windows 11 22621.963
    Computer type
    Laptop
    Manufacturer/Model
    HP Spectre x360, 2021 model, customized.
    CPU
    i7 11th gen
    Motherboard
    OEM
    Memory
    32GB
    Graphics Card(s)
    Iris Xe on Soc + NVIDIA 3050 discrete
    Sound Card
    Realtek?
    Monitor(s) Displays
    16" 4k OLED panel w/touch and pen
    Screen Resolution
    3840×2400
    Hard Drives
    Hynix NVMe 1TB
    PSU
    OEM
    Case
    OEM
    Cooling
    OEM
    Keyboard
    OEM
    Mouse
    OEM Touchpad; Logi Ergo Trackball BT
    Internet Speed
    Cable, 300/10 Mbps
    Browser
    FF, Edge, Chrome
    Antivirus
    Windows Defender
    Other Info
    NVIDIA mostly reserved CUDA development; main graphic is the Xe.
  • Operating System
    Windows 11 22621.963
    Computer type
    PC/Desktop
    Manufacturer/Model
    Quiet PC Ltd., UK. Bespoke.
    CPU
    Intel i7 12th gen
    Motherboard
    ASUS Prime Z-690D P4
    Memory
    128 GB
    Graphics card(s)
    Intel Xe on-Soc + NVIDIA 3070 Ti @ PCIe x16
    Sound Card
    Realtek, on-board
    Monitor(s) Displays
    LG UltraFine 5K 220 ppi on Thunderbolt ext bus
    Screen Resolution
    5120x2880
    Hard Drives
    NVMe Samsung SSD 980 PRO 1TB (SoC x4 PCIe)
    2× NVMe Samsung SSD 980 EVO Plus 2TB (PCH x4 PCIe each)
    PSU
    800W, +35% headroom to requrements.
    Case
    be Quiet!, the most basic one
    Cooling
    Noctua CPU cooler and case fans, to TDP/airflow spec
    Mouse
    Logi Ergo Trackball, BT
    Keyboard
    Present
    Internet Speed
    Cable, 300/10 Mbps
    Browser
    FF, Edge
    Antivirus
    Windows Defender
    Other Info
    Main workstation.
    Display is on the Xe; NVIDIA dedicated to CUDA compute only.
    Guest Debian Hyper-V VM, required for xplat work.
    Add-on PCIe cards:
    * ASUS, Intel AX201 Wireless @5GHz (home Ethernet wiring deteriorated).
    * ASUS Thunderbold EX 4, for display only.
What I did was so easy, and now I see it getting complicated! :devilish:

I have to keep everything simple and easy, because I have 12 PC's of my own and I also service a database of around 100 customers. All with different PC's, OS's and wants and needs. And some of those won't do a danged thing for themselves, so I have to do it for them.
But every PC, from XP to 11 generate tons of garbage that needs to be taken out on a regular basis.

Ergo my original XPCleanup.bat file. If I could count on the owner/operator to run it at least once a week, I'd just leave it on their desktop.
But if I was pretty sure it would NEVER be run, I'd just put it in their Startup Folder, so it would run silently in the background every time they booted up their PC. I also SILENTLY ran a little script to force the creation of a new Restore Point, with every boot up.
Getting some people to do what's necessary to maintain their PC, is like herding cats! :lmao:

I've run my Cleanup.bat program twice over the past two days, here on my own PC and the first time it removed 1186 files, and the second time it removed 1726 files. One thing my little old PC can do really FAST, is collect garbage. And that's about all she can do fast, with only a 2-Core Athlon cpu, 3.75GB of usable ram, and a 500GB SSD. She's so old, I have to crank her, to get her started!:lmao:
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
I know you asked for a bat file but I use this .reg file from the context menu. It has (2) choices to empty the trash:
1) With Confirmation
2) Without Confirmation

Below is the code:
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\empty]
"CommandStateHandler"="{c9298eef-69dd-4cdd-b153-bdbc38486781}"
"Description"="@shell32.dll,-31332"
"Icon"="shell32.dll,-254"
"MUIVerb"="@shell32.dll,-10564"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\empty\command]
"DelegateExecute"="{48527bb3-e8de-450b-8910-8c4099cb8624}"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\empty\shell\001flyout]
"MUIVerb"="with confirmation"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\empty\shell\001flyout\command]
"DelegateExecute"="{48527bb3-e8de-450b-8910-8c4099cb8624}"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\empty\shell\002flyout]
"MUIVerb"="without confirmation"
"CommandFlags"=dword:00000020

[HKEY_CLASSES_ROOT\Directory\Background\Shell\empty\shell\002flyout\command]
@="PowerShell -WindowStyle Hidden Clear-RecycleBin -force -ErrorAction:Ignore"

OSS
 

My Computer

System One

  • OS
    Windows 11
Good luck with that!
For me, 79 and counting, that might as well be written in Russian. Thanks anyway. I always appreciate your input.
Cheers!
TM :cool:
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
On my end, this is getting intense, or some might call it just plain CRAZY.
On reviewing my batch file, I realized that I was not addressing the cache of Temporary Internet Files generated by Firefox or Edge.
So I did a little research and found the address of where those files live.
First, I added the location of the Firefox files to my batch file and ran it. WOW, on the one run, it deleted 9,430 Temporary Internet Files.
Then, I added the location of the Edge files to my batch file and ran it. Wowsers! 1,443 Edge temp files were deleted.
It's only Thursday evening, and so far this week, my little home brew Cleanup program has removed 490,745 garbage files. I didn't count the Megabytes, but it's significant.

So when I do my weekly C: drive backup, those 490,745 files will not be going into my Backup.
I took this screen shot, at the end of my Cleanup earlier this evening.
Cleanup 1-12-23.jpg

It is my sincere hope, that all this work I've done this week will not go to waste, but that more people will get serious about keeping their own HD clean of junk.
Cheers Mates!
TM :cool:
PS: There's also "Tracking Cookies" that can be as bad as a virus, and "Super Anti Spyware" does a great job of getting rid of those.
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
I'm applying these options using a GPO, so I can apply the subset of common settings that I always use use to every machine. You just set the number of days there. The caveat is, GPO is unavailable in the Home edition. It might still be settable directly in the registry—this is what the Group Policy Object does when applied. Google for the exact policy name, some tables list the registry keys (whether the Home Ed. pays any attention to these settings, I dunno but vaguely remember it does).

If you apply a GPO, the controls on the corresponding page in Options will be greyed out, and there will be a message “some settings are managed by your organization”—the GPO is a domain thing, this is how admins apply settings to all computers in a domain. Just don't be startled by this.

This template is under Computer/Administrative Templates/System/Storage Sense (the path is not on the screenshot).

View attachment 49586


ADDED: There ya go!

Thank you cy_kkm. Perfect! We have recycle bins on both the C drive, and a newly partitioned D (data) drive. Do you know if the GPO (or controls in Settings for that matter) apply to both? Is there a way to limit deletion to C:\$Recycle.bin but not D:\$Recycle.bin"?
Shawn's Powershell command (option 6, referenced above) allows specification of a drive, but I wasn't successful adding an "where file is older than" criteria to the script.
 

My Computers

System One System Two

  • OS
    Windows 11 22H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell XPS8950
    CPU
    i7-12700K
    Motherboard
    Z690 : 9D2HH Foxconn, R6PCT Foxconn 2nd
    Memory
    16GB (2 x 8)
    Graphics Card(s)
    Intel(R) UHD Graphics 770 with shared graphics memory
    Sound Card
    Integrated
    Monitor(s) Displays
    Acer CBL282K Smiiprx
    Screen Resolution
    4K UHD (3840 x 2160) @ 60 Hz
    Hard Drives
    Western Digital PC SN810 512 GB M.2 NVMe SSD, PCIe
    PSU
    750W
    Cooling
    2G44F Asetek 125W CPU liquid cooler
    Keyboard
    Arteck Wireless
    Mouse
    Victsing-mm057 wireless
    Internet Speed
    Wi-Fi 6
    Browser
    Vivaldi
    Antivirus
    Windows Defender (native)
  • Operating System
    Win 22H2
    Computer type
    Laptop
    Manufacturer/Model
    Dell Vostro 5620
    CPU
    12th Gen Intel Core i7-1260P
    Memory
    2 x 8 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Screen Resolution
    1920 x 1200 @ 60 Hz
    Hard Drives
    NVMe 512 GB
    Case
    Aluminum
    Mouse
    Touchpad
    Browser
    Vivaldi
    Antivirus
    Windows Defender (native)
Hello mate, :alien:

You might test option six below to see if the command in it may for work with your BAT file.

Thank you for this, Shawn. It was very helpful.
I tried adding date-based criteria to your Powershell command, but was unsuccessful. I tried piping:
Powershell:
PowerShell Clear-RecycleBin -DriveLetter C | where {$_.ModifyDate -lt (get-date).AddDays(-$Days)} -force -ErrorAction:Ignore
but it didn't work.
 

My Computers

System One System Two

  • OS
    Windows 11 22H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell XPS8950
    CPU
    i7-12700K
    Motherboard
    Z690 : 9D2HH Foxconn, R6PCT Foxconn 2nd
    Memory
    16GB (2 x 8)
    Graphics Card(s)
    Intel(R) UHD Graphics 770 with shared graphics memory
    Sound Card
    Integrated
    Monitor(s) Displays
    Acer CBL282K Smiiprx
    Screen Resolution
    4K UHD (3840 x 2160) @ 60 Hz
    Hard Drives
    Western Digital PC SN810 512 GB M.2 NVMe SSD, PCIe
    PSU
    750W
    Cooling
    2G44F Asetek 125W CPU liquid cooler
    Keyboard
    Arteck Wireless
    Mouse
    Victsing-mm057 wireless
    Internet Speed
    Wi-Fi 6
    Browser
    Vivaldi
    Antivirus
    Windows Defender (native)
  • Operating System
    Win 22H2
    Computer type
    Laptop
    Manufacturer/Model
    Dell Vostro 5620
    CPU
    12th Gen Intel Core i7-1260P
    Memory
    2 x 8 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Screen Resolution
    1920 x 1200 @ 60 Hz
    Hard Drives
    NVMe 512 GB
    Case
    Aluminum
    Mouse
    Touchpad
    Browser
    Vivaldi
    Antivirus
    Windows Defender (native)
You can't select files using Clear-RecycleBin, it's all or nothing for that drive(s).
 

My Computer

System One

  • OS
    Windows 7

Latest Support Threads

Back
Top Bottom