dwgx@blog:~$dwgx
> cd ../posts

CleanerKing: Folding Windows Cleanup Into a Single CLI

// created

CleanerKing is a command-line tool for cleaning up Windows. It takes the chores that normally mean clicking through a pile of GUIs, or memorizing a string of cleanmgr msconfig chkdsk commands, cleaning temp files, caches, SoftwareDistribution, Prefetch, Recent, and folds them into one console program. Launch it, pick from the menu, and it runs the whole thing in one pass.

Written in Java. For this kind of script PowerShell is more native, but I went with Java to practice modularity and to have a skeleton I could keep adding features to over the long haul. source/target are locked to 1.8, Maven handles dependencies, interaction goes through jLine 3.28, and logging uses slf4j. The entry point is org.CleanerKing.Client; main() registers the modules into the menu, so startup is just a plain command-line menu. Windows-only, the commands and paths it calls are all the Windows set, no plans to go cross-platform.

Each feature is a Module registered into the ModuleManager, and the menu lists them automatically. One-click cleanup is the one I use most: it clears user and system temp directories, the recycle bin, SoftwareDistribution/Prefetch/Recent, Edge/Chrome/Firefox caches, and flushes DNS on the way out. If you want to be precise, use advanced cleanup and check off your own targets instead of nuking everything at once. The rest of the pieces: shortcut launchers for cleanmgr diskmgmt.msc msconfig chkdsk taskmgr so you don’t have to remember them, file search that finds and deletes by size, date, and regex, and a DNS module that reads your network adapters and configures DNS. Settings are stored in config.properties, generated automatically if it doesn’t exist.

The console also gets a 3D ASCII title, a loading animation, and ANSI color output, pure self-indulgence, something to open once a day for the mood of it.

Building is just mvn clean package, and the JAR lands under target. Remember to set the encoding when you run it:

java -Dfile.encoding=UTF-8 -jar CleanerKing.jar

A couple of gotchas to note up front: the cleanup and DNS parts need administrator privileges, so you have to launch from an elevated terminal, otherwise a bunch of operations fail silently. The pom currently has no shade/assembly plugin, so to run the JAR standalone you have to stuff jLine and slf4j into the classpath yourself, something to fix later.

The version is still 1.0-SNAPSHOT. The core all works, and there’s a slot reserved in the menu for network repair, the code isn’t finished so it’s just a placeholder for now. It’s not a product, just a handy gadget on my own machine, and whenever something annoys me I bolt another piece onto it.