From 661105670cba704124f3d38145a0385c1dd3babd Mon Sep 17 00:00:00 2001 From: Bhadra Date: Mon, 12 Jan 2026 11:58:20 +0530 Subject: [PATCH 01/10] feat: add GPU shader cache cleanup (NVIDIA, AMD, Intel, DirectX) Add Clear-GPUShaderCaches function to clean GPU shader caches: - NVIDIA: DXCache, GLCache, NV_Cache - AMD: DXCache, GLCache, VkCache - Intel: ShaderCache - DirectX: D3DSCache, DirectX Shader Cache - Vulkan: VulkanCache (pipeline cache) These caches can grow to 10GB+ and are safe to delete. They will be rebuilt automatically when needed. Integrated into main clean.ps1 workflow. --- bin/clean.ps1 | 3 ++ lib/clean/caches.ps1 | 81 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/bin/clean.ps1 b/bin/clean.ps1 index ce66194..4e07f1f 100644 --- a/bin/clean.ps1 +++ b/bin/clean.ps1 @@ -230,6 +230,9 @@ function Start-Cleanup { # Browser caches Clear-BrowserCaches + # GPU shader caches (NVIDIA, AMD, Intel, DirectX) + Clear-GPUShaderCaches + # Application caches Clear-AppCaches diff --git a/lib/clean/caches.ps1 b/lib/clean/caches.ps1 index bba2550..e48832f 100644 --- a/lib/clean/caches.ps1 +++ b/lib/clean/caches.ps1 @@ -337,6 +337,79 @@ function Clear-DotNetCaches { # Assembly cache (don't touch - managed by CLR) } +# ============================================================================ +# GPU Shader Caches +# ============================================================================ + +function Clear-GPUShaderCaches { + <# + .SYNOPSIS + Clean GPU shader caches (NVIDIA, AMD, Intel, DirectX) + .DESCRIPTION + GPU drivers cache compiled shaders to improve game/app load times. + These caches can grow very large (10GB+) and are safe to delete. + They will be rebuilt automatically when needed. + #> + + Start-Section "GPU shader caches" + + # NVIDIA shader caches + $nvidiaCachePaths = @( + "$env:LOCALAPPDATA\NVIDIA\DXCache" + "$env:LOCALAPPDATA\NVIDIA\GLCache" + "$env:LOCALAPPDATA\NVIDIA Corporation\NV_Cache" + "$env:TEMP\NVIDIA Corporation\NV_Cache" + ) + foreach ($path in $nvidiaCachePaths) { + if (Test-Path $path) { + Clear-DirectoryContents -Path $path -Description "NVIDIA shader cache" + } + } + + # AMD shader caches + $amdCachePaths = @( + "$env:LOCALAPPDATA\AMD\DXCache" + "$env:LOCALAPPDATA\AMD\GLCache" + "$env:LOCALAPPDATA\AMD\VkCache" + ) + foreach ($path in $amdCachePaths) { + if (Test-Path $path) { + Clear-DirectoryContents -Path $path -Description "AMD shader cache" + } + } + + # Intel shader caches + $intelCachePaths = @( + "$env:LOCALAPPDATA\Intel\ShaderCache" + "$env:APPDATA\Intel\ShaderCache" + ) + foreach ($path in $intelCachePaths) { + if (Test-Path $path) { + Clear-DirectoryContents -Path $path -Description "Intel shader cache" + } + } + + # DirectX shader cache (system-wide) + $dxCachePath = "$env:LOCALAPPDATA\D3DSCache" + if (Test-Path $dxCachePath) { + Clear-DirectoryContents -Path $dxCachePath -Description "DirectX shader cache" + } + + # DirectX pipeline cache + $dxPipelinePath = "$env:LOCALAPPDATA\Microsoft\DirectX Shader Cache" + if (Test-Path $dxPipelinePath) { + Clear-DirectoryContents -Path $dxPipelinePath -Description "DirectX pipeline cache" + } + + # Vulkan pipeline cache (common location) + $vulkanCachePath = "$env:LOCALAPPDATA\VulkanCache" + if (Test-Path $vulkanCachePath) { + Clear-DirectoryContents -Path $vulkanCachePath -Description "Vulkan pipeline cache" + } + + Stop-Section +} + # ============================================================================ # Main Cache Cleanup Function # ============================================================================ @@ -349,7 +422,8 @@ function Invoke-CacheCleanup { param( [switch]$IncludeWindowsUpdate, [switch]$IncludeBrowsers, - [switch]$IncludeApps + [switch]$IncludeApps, + [switch]$IncludeGPU ) Start-Section "System caches" @@ -368,6 +442,11 @@ function Invoke-CacheCleanup { Stop-Section + # GPU shader caches + if ($IncludeGPU) { + Clear-GPUShaderCaches + } + # Browser caches if ($IncludeBrowsers) { Clear-BrowserCaches From afe8d09c7c8490d95e97817964ea40be7de02682 Mon Sep 17 00:00:00 2001 From: Bhadra Date: Mon, 12 Jan 2026 12:01:48 +0530 Subject: [PATCH 02/10] feat: add repair command with cache rebuilds and system fixes Add new 'mole repair' command with the following utilities: - DNS cache flush (Repair-DnsCache) - Font cache rebuild (Repair-FontCache) - requires admin - Icon cache rebuild (Repair-IconCache) - restarts Explorer - Windows Search index reset (Repair-SearchIndex) - requires admin - Windows Store cache reset (Repair-StoreCache) - runs wsreset.exe Features: - Interactive menu when run without arguments - Command-line flags: -DNS, -Font, -Icon, -Search, -Store, -All - Dry-run mode support - Proper service stop/start for font and search repairs Usage: mole repair # Interactive menu mole repair -DNS # Flush DNS only mole repair -All # Run all repairs --- bin/repair.ps1 | 487 +++++++++++++++++++++++++++++++++++++++++++++++++ mole.ps1 | 9 + 2 files changed, 496 insertions(+) create mode 100644 bin/repair.ps1 diff --git a/bin/repair.ps1 b/bin/repair.ps1 new file mode 100644 index 0000000..61adc0c --- /dev/null +++ b/bin/repair.ps1 @@ -0,0 +1,487 @@ +# Mole - Repair Command +# System repair utilities for Windows (cache rebuilds, resets) + +#Requires -Version 5.1 +[CmdletBinding()] +param( + [switch]$DryRun, + [switch]$DebugMode, + [switch]$ShowHelp, + [switch]$All, + [switch]$DNS, + [switch]$Font, + [switch]$Icon, + [switch]$Search, + [switch]$Store +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" + +# Script location +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path +$libDir = Join-Path (Split-Path -Parent $scriptDir) "lib" + +# Import core modules +. "$libDir\core\base.ps1" +. "$libDir\core\log.ps1" +. "$libDir\core\ui.ps1" + +# ============================================================================ +# Configuration +# ============================================================================ + +$script:RepairsApplied = 0 +$script:IsDryRun = $DryRun -or ($env:MOLE_DRY_RUN -eq "1") + +# ============================================================================ +# Help +# ============================================================================ + +function Show-RepairHelp { + $esc = [char]27 + Write-Host "" + Write-Host "$esc[1;35mMole Repair$esc[0m - System repair utilities" + Write-Host "" + Write-Host "$esc[33mUsage:$esc[0m mole repair [options]" + Write-Host "" + Write-Host "$esc[33mOptions:$esc[0m" + Write-Host " -All Run all repairs" + Write-Host " -DNS Flush DNS cache" + Write-Host " -Font Rebuild font cache" + Write-Host " -Icon Rebuild icon cache" + Write-Host " -Search Reset Windows Search index" + Write-Host " -Store Reset Windows Store cache" + Write-Host "" + Write-Host " -DryRun Preview repairs without applying" + Write-Host " -DebugMode Enable debug logging" + Write-Host " -ShowHelp Show this help message" + Write-Host "" + Write-Host "$esc[33mExamples:$esc[0m" + Write-Host " mole repair -DNS Flush DNS cache" + Write-Host " mole repair -Icon -Font Rebuild icon and font caches" + Write-Host " mole repair -All Run all repairs" + Write-Host "" +} + +# ============================================================================ +# Repair Functions +# ============================================================================ + +function Repair-DnsCache { + <# + .SYNOPSIS + Flush DNS resolver cache + .DESCRIPTION + Clears the DNS client cache, forcing fresh DNS lookups. + Useful when DNS records have changed or you're having connectivity issues. + #> + + $esc = [char]27 + + Write-Host "" + Write-Host "$esc[34m$($script:Icons.Arrow) DNS Cache Flush$esc[0m" + + if ($script:IsDryRun) { + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would flush DNS cache" + $script:RepairsApplied++ + return + } + + try { + Clear-DnsClientCache -ErrorAction Stop + Write-Host " $esc[32m$($script:Icons.Success)$esc[0m DNS cache flushed successfully" + $script:RepairsApplied++ + } + catch { + Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not flush DNS cache: $_" + } +} + +function Repair-FontCache { + <# + .SYNOPSIS + Rebuild Windows font cache + .DESCRIPTION + Stops the font cache service, clears the cache files, and restarts. + Fixes issues with fonts not displaying correctly or missing fonts. + #> + + $esc = [char]27 + + Write-Host "" + Write-Host "$esc[34m$($script:Icons.Arrow) Font Cache Rebuild$esc[0m" + + if (-not (Test-IsAdmin)) { + Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Requires administrator privileges" + return + } + + # Font cache locations + $fontCachePaths = @( + "$env:LOCALAPPDATA\Microsoft\Windows\Fonts" + "$env:WINDIR\ServiceProfiles\LocalService\AppData\Local\FontCache" + "$env:WINDIR\System32\FNTCACHE.DAT" + ) + + if ($script:IsDryRun) { + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Windows Font Cache Service" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete font cache files" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Windows Font Cache Service" + $script:RepairsApplied++ + return + } + + try { + # Stop font cache service + Write-Host " $esc[90mStopping Font Cache Service...$esc[0m" + Stop-Service -Name "FontCache" -Force -ErrorAction SilentlyContinue + Stop-Service -Name "FontCache3.0.0.0" -Force -ErrorAction SilentlyContinue + + # Wait a moment for service to stop + Start-Sleep -Seconds 2 + + # Delete font cache files + foreach ($path in $fontCachePaths) { + if (Test-Path $path) { + if (Test-Path $path -PathType Container) { + # Directory - clear contents + Get-ChildItem -Path $path -Recurse -Force -ErrorAction SilentlyContinue | + Remove-Item -Force -Recurse -ErrorAction SilentlyContinue + } + else { + # File - delete it + Remove-Item -Path $path -Force -ErrorAction SilentlyContinue + } + } + } + + # Restart font cache service + Write-Host " $esc[90mRestarting Font Cache Service...$esc[0m" + Start-Service -Name "FontCache" -ErrorAction SilentlyContinue + Start-Service -Name "FontCache3.0.0.0" -ErrorAction SilentlyContinue + + Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Font cache rebuilt successfully" + Write-Host " $esc[90mNote: Some apps may need restart to see changes$esc[0m" + $script:RepairsApplied++ + } + catch { + Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not rebuild font cache: $_" + # Try to restart services even if we failed + Start-Service -Name "FontCache" -ErrorAction SilentlyContinue + } +} + +function Repair-IconCache { + <# + .SYNOPSIS + Rebuild Windows icon cache + .DESCRIPTION + Clears the icon cache database files, forcing Windows to rebuild them. + Fixes issues with missing, corrupted, or outdated icons. + #> + + $esc = [char]27 + + Write-Host "" + Write-Host "$esc[34m$($script:Icons.Arrow) Icon Cache Rebuild$esc[0m" + + # Icon cache locations + $iconCachePath = "$env:LOCALAPPDATA\Microsoft\Windows\Explorer" + $thumbCachePath = "$env:LOCALAPPDATA\Microsoft\Windows\Explorer" + + if ($script:IsDryRun) { + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Explorer" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete icon cache files (iconcache_*.db)" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Explorer" + $script:RepairsApplied++ + return + } + + try { + Write-Host " $esc[90mStopping Explorer...$esc[0m" + + # Kill explorer (will restart automatically, or we restart it) + Stop-Process -Name "explorer" -Force -ErrorAction SilentlyContinue + + # Wait for explorer to fully stop + Start-Sleep -Seconds 2 + + # Delete icon cache files + $iconCacheFiles = Get-ChildItem -Path $iconCachePath -Filter "iconcache_*.db" -Force -ErrorAction SilentlyContinue + $thumbCacheFiles = Get-ChildItem -Path $thumbCachePath -Filter "thumbcache_*.db" -Force -ErrorAction SilentlyContinue + + $deletedCount = 0 + foreach ($file in $iconCacheFiles) { + Remove-Item -Path $file.FullName -Force -ErrorAction SilentlyContinue + $deletedCount++ + } + + # Also clear thumbcache for good measure + foreach ($file in $thumbCacheFiles) { + Remove-Item -Path $file.FullName -Force -ErrorAction SilentlyContinue + $deletedCount++ + } + + # Also clear the system-wide icon cache + $systemIconCache = "$env:LOCALAPPDATA\IconCache.db" + if (Test-Path $systemIconCache) { + Remove-Item -Path $systemIconCache -Force -ErrorAction SilentlyContinue + $deletedCount++ + } + + Write-Host " $esc[90mRestarting Explorer...$esc[0m" + + # Restart explorer + Start-Process "explorer.exe" + + Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Icon cache rebuilt ($deletedCount files cleared)" + Write-Host " $esc[90mNote: Icons will rebuild gradually as you browse$esc[0m" + $script:RepairsApplied++ + } + catch { + Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not rebuild icon cache: $_" + # Make sure explorer is running + Start-Process "explorer.exe" -ErrorAction SilentlyContinue + } +} + +function Repair-SearchIndex { + <# + .SYNOPSIS + Reset Windows Search index + .DESCRIPTION + Stops the Windows Search service, deletes the search index, and restarts. + Fixes issues with search not finding files or returning incorrect results. + Note: Rebuilding the index can take hours depending on file count. + #> + + $esc = [char]27 + + Write-Host "" + Write-Host "$esc[34m$($script:Icons.Arrow) Windows Search Index Reset$esc[0m" + + if (-not (Test-IsAdmin)) { + Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Requires administrator privileges" + return + } + + $searchIndexPath = "$env:ProgramData\Microsoft\Search\Data\Applications\Windows" + + if ($script:IsDryRun) { + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Windows Search service" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete search index database" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Windows Search service" + $script:RepairsApplied++ + return + } + + try { + Write-Host " $esc[90mStopping Windows Search service...$esc[0m" + Stop-Service -Name "WSearch" -Force -ErrorAction Stop + + # Wait for service to fully stop + Start-Sleep -Seconds 3 + + # Delete search index + if (Test-Path $searchIndexPath) { + Write-Host " $esc[90mDeleting search index...$esc[0m" + Remove-Item -Path "$searchIndexPath\*" -Recurse -Force -ErrorAction SilentlyContinue + } + + Write-Host " $esc[90mRestarting Windows Search service...$esc[0m" + Start-Service -Name "WSearch" -ErrorAction Stop + + Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Search index reset successfully" + Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Indexing will rebuild in the background (may take hours)" + $script:RepairsApplied++ + } + catch { + Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not reset search index: $_" + # Try to restart service + Start-Service -Name "WSearch" -ErrorAction SilentlyContinue + } +} + +function Repair-StoreCache { + <# + .SYNOPSIS + Reset Windows Store cache + .DESCRIPTION + Runs wsreset.exe to clear the Windows Store cache. + Fixes issues with Store apps not installing, updating, or launching. + #> + + $esc = [char]27 + + Write-Host "" + Write-Host "$esc[34m$($script:Icons.Arrow) Windows Store Cache Reset$esc[0m" + + if ($script:IsDryRun) { + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would run wsreset.exe" + $script:RepairsApplied++ + return + } + + try { + Write-Host " $esc[90mResetting Windows Store cache...$esc[0m" + + # wsreset.exe clears the store cache and reopens the Store + $wsreset = Start-Process -FilePath "wsreset.exe" -PassThru -WindowStyle Hidden + + # Wait for it to complete (usually quick) + $wsreset.WaitForExit(30000) # 30 second timeout + + if ($wsreset.ExitCode -eq 0) { + Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Windows Store cache reset successfully" + $script:RepairsApplied++ + } + else { + Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m wsreset completed with code $($wsreset.ExitCode)" + $script:RepairsApplied++ + } + } + catch { + Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not reset Store cache: $_" + } +} + +# ============================================================================ +# Interactive Menu +# ============================================================================ + +function Show-RepairMenu { + $esc = [char]27 + + $menuItems = @( + @{ Key = "1"; Label = "DNS Cache"; Desc = "Flush DNS resolver cache"; Action = { Repair-DnsCache } } + @{ Key = "2"; Label = "Font Cache"; Desc = "Rebuild font cache (Admin)"; Action = { Repair-FontCache } } + @{ Key = "3"; Label = "Icon Cache"; Desc = "Rebuild icon cache"; Action = { Repair-IconCache } } + @{ Key = "4"; Label = "Search Index"; Desc = "Reset Windows Search (Admin)"; Action = { Repair-SearchIndex } } + @{ Key = "5"; Label = "Store Cache"; Desc = "Reset Windows Store cache"; Action = { Repair-StoreCache } } + @{ Key = "A"; Label = "All Repairs"; Desc = "Run all of the above"; Action = { + Repair-DnsCache + Repair-FontCache + Repair-IconCache + Repair-SearchIndex + Repair-StoreCache + } } + @{ Key = "Q"; Label = "Quit"; Desc = "Exit"; Action = $null } + ) + + Write-Host "" + Write-Host "$esc[1;35m$($script:Icons.Mole) Mole Repair$esc[0m" + Write-Host "" + + if ($script:IsDryRun) { + Write-Host "$esc[33m$($script:Icons.DryRun) DRY RUN MODE$esc[0m - No changes will be made" + Write-Host "" + } + + Write-Host "$esc[90mSelect a repair to run:$esc[0m" + Write-Host "" + + foreach ($item in $menuItems) { + Write-Host " $esc[36m[$($item.Key)]$esc[0m $($item.Label) - $esc[90m$($item.Desc)$esc[0m" + } + + Write-Host "" + $choice = Read-Host "Choice" + + $selected = $menuItems | Where-Object { $_.Key -eq $choice.ToUpper() } + + if ($selected -and $selected.Action) { + & $selected.Action + + # Show summary + Write-Host "" + if ($script:RepairsApplied -gt 0) { + Write-Host "$esc[32m$($script:Icons.Success)$esc[0m $($script:RepairsApplied) repair(s) applied" + } + else { + Write-Host "$esc[90mNo repairs applied$esc[0m" + } + } + elseif ($choice.ToUpper() -eq "Q") { + return + } + else { + Write-Host "$esc[31mInvalid choice$esc[0m" + } +} + +# ============================================================================ +# Main Entry Point +# ============================================================================ + +function Main { + $esc = [char]27 + + # Enable debug if requested + if ($DebugMode) { + $env:MOLE_DEBUG = "1" + $DebugPreference = "Continue" + } + + # Show help + if ($ShowHelp) { + Show-RepairHelp + return + } + + # Check if any specific repair was requested + $specificRepair = $DNS -or $Font -or $Icon -or $Search -or $Store -or $All + + if (-not $specificRepair) { + # No specific repair requested - show interactive menu + Show-RepairMenu + return + } + + # Run specific repairs + Write-Host "" + Write-Host "$esc[1;35m$($script:Icons.Mole) Mole Repair$esc[0m" + + if ($script:IsDryRun) { + Write-Host "" + Write-Host "$esc[33m$($script:Icons.DryRun) DRY RUN MODE$esc[0m - No changes will be made" + } + + if ($All -or $DNS) { + Repair-DnsCache + } + + if ($All -or $Font) { + Repair-FontCache + } + + if ($All -or $Icon) { + Repair-IconCache + } + + if ($All -or $Search) { + Repair-SearchIndex + } + + if ($All -or $Store) { + Repair-StoreCache + } + + # Show summary + Write-Host "" + if ($script:RepairsApplied -gt 0) { + if ($script:IsDryRun) { + Write-Host "$esc[33m$($script:Icons.DryRun)$esc[0m $($script:RepairsApplied) repair(s) would be applied" + } + else { + Write-Host "$esc[32m$($script:Icons.Success)$esc[0m $($script:RepairsApplied) repair(s) applied successfully" + } + } + else { + Write-Host "$esc[90mNo repairs applied$esc[0m" + } + Write-Host "" +} + +# Run main +Main diff --git a/mole.ps1 b/mole.ps1 index f5c5eab..ad904d4 100644 --- a/mole.ps1 +++ b/mole.ps1 @@ -62,6 +62,7 @@ function Show-MainHelp { Write-Host " ${cyan}analyze${nc} Visual disk space analyzer" Write-Host " ${cyan}status${nc} Real-time system monitor" Write-Host " ${cyan}optimize${nc} System optimization tasks" + Write-Host " ${cyan}repair${nc} Cache rebuilds and system fixes" Write-Host " ${cyan}purge${nc} Clean project build artifacts" Write-Host "" Write-Host " ${green}OPTIONS:${nc}" @@ -78,6 +79,8 @@ function Show-MainHelp { Write-Host " ${gray}mole analyze${nc} ${gray}# Disk analyzer${nc}" Write-Host " ${gray}mole status${nc} ${gray}# System monitor${nc}" Write-Host " ${gray}mole optimize${nc} ${gray}# Optimize system${nc}" + Write-Host " ${gray}mole repair -DNS${nc} ${gray}# Flush DNS cache${nc}" + Write-Host " ${gray}mole repair -All${nc} ${gray}# Run all repairs${nc}" Write-Host " ${gray}mole purge${nc} ${gray}# Clean dev artifacts${nc}" Write-Host "" Write-Host " ${green}ENVIRONMENT:${nc}" @@ -125,6 +128,12 @@ function Show-MainMenu { Command = "optimize" Icon = $script:Icons.Arrow } + @{ + Name = "Repair" + Description = "Cache rebuilds & fixes" + Command = "repair" + Icon = $script:Icons.Admin + } @{ Name = "Purge" Description = "Clean dev artifacts" From 1e75d916df2124b8304c8ae34f9efbe3ffc90fb4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 12 Jan 2026 06:32:27 +0000 Subject: [PATCH 03/10] chore: update contributors [skip ci] --- CONTRIBUTORS.svg | 78 +++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/CONTRIBUTORS.svg b/CONTRIBUTORS.svg index b92e4ba..7c22074 100644 --- a/CONTRIBUTORS.svg +++ b/CONTRIBUTORS.svg @@ -1,4 +1,4 @@ - + @@ -13,6 +13,17 @@ + + + + + + + + bhadraagada + + + @@ -23,7 +34,7 @@ JackPhallen - + @@ -34,7 +45,7 @@ amanthanvi - + @@ -45,7 +56,7 @@ alexandear - + @@ -56,7 +67,18 @@ rubnogueira - + + + + + + + + + biplavbarua + + + @@ -67,7 +89,7 @@ bsisduck - + @@ -78,7 +100,7 @@ jimmystridh - + @@ -89,7 +111,7 @@ fte-jjmartres - + @@ -100,7 +122,7 @@ Else00 - + @@ -111,7 +133,7 @@ carolyn-sun - + @@ -122,7 +144,7 @@ purofle - + @@ -133,7 +155,7 @@ huyixi - + @@ -144,7 +166,7 @@ bunizao - + @@ -155,7 +177,7 @@ zeldrisho - + @@ -166,7 +188,7 @@ yuzeguitarist - + @@ -177,7 +199,7 @@ thijsvanhal - + @@ -188,7 +210,7 @@ Sizk - + @@ -199,7 +221,7 @@ ndbroadbent - + @@ -210,7 +232,7 @@ MohammedEsafi - + @@ -221,7 +243,7 @@ Schlauer-Hax - + @@ -232,7 +254,7 @@ anonymort - + @@ -243,7 +265,7 @@ khipu-luke - + @@ -254,7 +276,7 @@ LmanTW - + @@ -265,7 +287,7 @@ kwakubiney - + @@ -276,7 +298,7 @@ kowyo - + @@ -287,7 +309,7 @@ jalen0x - + @@ -298,7 +320,7 @@ Hensell - + @@ -309,7 +331,7 @@ ClathW - + From a2f0ae607889d8fe9b5f6fef684dfd5590eb160b Mon Sep 17 00:00:00 2001 From: Bhadra Date: Mon, 12 Jan 2026 12:14:15 +0530 Subject: [PATCH 04/10] fix: repair command icon and null input handling - Replace non-existent Icons.Mole with Icons.Admin - Add null check for empty menu input --- bin/repair.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/repair.ps1 b/bin/repair.ps1 index 61adc0c..1942a75 100644 --- a/bin/repair.ps1 +++ b/bin/repair.ps1 @@ -370,7 +370,7 @@ function Show-RepairMenu { ) Write-Host "" - Write-Host "$esc[1;35m$($script:Icons.Mole) Mole Repair$esc[0m" + Write-Host "$esc[1;35m$($script:Icons.Admin) Mole Repair$esc[0m" Write-Host "" if ($script:IsDryRun) { @@ -388,6 +388,10 @@ function Show-RepairMenu { Write-Host "" $choice = Read-Host "Choice" + if ([string]::IsNullOrWhiteSpace($choice)) { + return + } + $selected = $menuItems | Where-Object { $_.Key -eq $choice.ToUpper() } if ($selected -and $selected.Action) { @@ -440,7 +444,7 @@ function Main { # Run specific repairs Write-Host "" - Write-Host "$esc[1;35m$($script:Icons.Mole) Mole Repair$esc[0m" + Write-Host "$esc[1;35m$($script:Icons.Admin) Mole Repair$esc[0m" if ($script:IsDryRun) { Write-Host "" From f019ea3d941d9dd8585ef3d04eb05f68e1de5947 Mon Sep 17 00:00:00 2001 From: Bhadra Date: Mon, 12 Jan 2026 12:19:29 +0530 Subject: [PATCH 05/10] chore: docs update --- README.md | 312 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 237 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 044fdcb..c01ac72 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,32 @@ -# Mole for Windows +
+

Mole

+

Deep clean and optimize your Windows.

+
-Windows support for [Mole](https://github.com/tw93/Mole) - A system maintenance toolkit. +

+ Stars + Version + License + Commits + Twitter + Telegram +

+ +

+ Mole - 95.50GB freed +

+ +## Features + +- **All-in-one toolkit**: CCleaner, IObit Uninstaller, WinDirStat, and Task Manager combined into a single PowerShell toolkit +- **Deep cleaning**: Scans and removes temp files, caches, and browser leftovers to reclaim gigabytes of space +- **Smart uninstaller**: Thoroughly removes apps along with AppData, preferences, and hidden remnants +- **Disk insights**: Visualizes usage, manages large files, and refreshes system services +- **Live monitoring**: Real-time stats for CPU, memory, disk, and network to diagnose performance issues + +## Platform Support + +Mole is designed for Windows 10/11. This is the native Windows version ported from the [macOS original](https://github.com/tw93/Mole/tree/main). For macOS users, please visit the [main branch](https://github.com/tw93/Mole) for the native macOS version. ## Requirements @@ -8,19 +34,206 @@ Windows support for [Mole](https://github.com/tw93/Mole) - A system maintenance - PowerShell 5.1 or later (pre-installed on Windows 10/11) - Go 1.24+ (for building TUI tools) -## Installation +## Quick Start -### Quick Install +Install via PowerShell: ```powershell -# Clone the repository -git clone https://github.com/tw93/Mole.git -cd Mole/windows +# Download and run installer (recommended) +iwr -Uri "https://raw.githubusercontent.com/tw93/mole/windows/install.ps1" -OutFile "$env:TEMP\mole-install.ps1"; & "$env:TEMP\mole-install.ps1" -AddToPath + +# Or install with specific options +# -Branch windows for latest code, -Tag v1.17.0 for specific version +iwr -Uri "https://raw.githubusercontent.com/tw93/mole/windows/install.ps1" -OutFile "$env:TEMP\mole-install.ps1"; & "$env:TEMP\mole-install.ps1" -AddToPath -CreateShortcut +``` + +Or install manually: + +```powershell +# Clone the repository and checkout windows branch +git clone -b windows https://github.com/tw93/Mole.git +cd Mole # Run the installer .\install.ps1 -AddToPath ``` +Run: + +```powershell +mole # Interactive menu +mole clean # Deep cleanup +mole uninstall # Remove apps + leftovers +mole optimize # Refresh caches & services +mole analyze # Visual disk explorer +mole status # Live system health dashboard +mole purge # Clean project build artifacts + +mole -ShowHelp # Show help +mole -Version # Show installed version + +mole clean -DryRun # Preview the cleanup plan +mole clean -Whitelist # Manage protected caches +mole clean -DryRun -Debug # Detailed preview with risk levels + +mole optimize -DryRun # Preview optimization actions +mole optimize -Debug # Run with detailed operation logs +mole purge -Paths # Configure project scan directories +``` + +## Tips + +- **Safety**: Built with strict protections. Preview changes with `mole clean -DryRun`. +- **Be Careful**: Although safe by design, file deletion is permanent. Please review operations carefully. +- **Debug Mode**: Use `-Debug` for detailed logs (e.g., `mole clean -Debug`). Combine with `-DryRun` for comprehensive preview including risk levels and file details. +- **Navigation**: Supports arrow keys for TUI navigation. +- **Configuration**: Use `mole clean -Whitelist` to manage protected paths, `mole purge -Paths` to configure scan directories. + +## Features in Detail + +### Deep System Cleanup + +```powershell +mole clean +``` + +``` +Scanning cache directories... + + ✓ User temp files 12.3GB + ✓ Browser cache (Chrome, Edge, Firefox) 8.5GB + ✓ Developer tools (Node.js, npm, Python) 15.2GB + ✓ Windows logs and temp files 4.1GB + ✓ App-specific cache (Spotify, Slack, VS Code) 6.8GB + ✓ Recycle Bin 9.2GB + +==================================================================== +Space freed: 56.1GB | Free space now: 180.3GB +==================================================================== +``` + +### Smart App Uninstaller + +```powershell +mole uninstall +``` + +``` +Select Apps to Remove +═══════════════════════════ +▶ ☑ Adobe Photoshop 2024 (4.2GB) | Old + ☐ IntelliJ IDEA (2.8GB) | Recent + ☐ Premiere Pro (3.4GB) | Recent + +Uninstalling: Adobe Photoshop 2024 + + ✓ Removed application + ✓ Cleaned 52 related files across 8 locations + - AppData, Caches, Preferences + - Logs, Registry entries + - Extensions, Plugins + +==================================================================== +Space freed: 4.8GB +==================================================================== +``` + +### System Optimization + +```powershell +mole optimize +``` + +``` +System: 12/32 GB RAM | 280/460 GB Disk (61%) | Uptime 6d + + ✓ Clear Windows Update cache + ✓ Reset DNS cache + ✓ Clean event logs and diagnostic reports + ✓ Refresh Windows Search index + ✓ Clear thumbnail cache + ✓ Optimize startup programs + +==================================================================== +System optimization completed +==================================================================== +``` + +### Disk Space Analyzer + +```powershell +mole analyze +``` + +``` +Analyze Disk C:\Users\YourName\Documents | Total: 156.8GB + + ▶ 1. ███████████████████ 48.2% | 📁 Downloads 75.4GB >6mo + 2. ██████████░░░░░░░░░ 22.1% | 📁 Videos 34.6GB + 3. ████░░░░░░░░░░░░░░░ 14.3% | 📁 Pictures 22.4GB + 4. ███░░░░░░░░░░░░░░░░ 10.8% | 📁 Documents 16.9GB + 5. ██░░░░░░░░░░░░░░░░░ 5.2% | 📄 backup_2023.zip 8.2GB + + ↑↓←→ Navigate | O Open | F Show | Del Delete | L Large files | Q Quit +``` + +### Live System Status + +Real-time dashboard with system health score, hardware info, and performance metrics. + +```powershell +mole status +``` + +``` +Mole Status Health ● 92 Desktop PC · Intel i7 · 32GB · Windows 11 + +⚙ CPU ▦ Memory +Total ████████████░░░░░░░ 45.2% Used ███████████░░░░░░░ 58.4% +Load 0.82 / 1.05 / 1.23 (8 cores) Total 18.7 / 32.0 GB +Core 1 ███████████████░░░░ 78.3% Free ████████░░░░░░░░░░ 41.6% +Core 2 ████████████░░░░░░░ 62.1% Avail 13.3 GB + +▤ Disk ⚡ Power +Used █████████████░░░░░░ 67.2% Status AC Power +Free 156.3 GB Temp 58°C +Read ▮▯▯▯▯ 2.1 MB/s +Write ▮▮▮▯▯ 18.3 MB/s + +⇅ Network ▶ Processes +Down ▮▮▯▯▯ 3.2 MB/s Code ▮▮▮▮▯ 42.1% +Up ▮▯▯▯▯ 0.8 MB/s Chrome ▮▮▮▯▯ 28.3% +``` + +Health score based on CPU, memory, disk, temperature, and I/O load. Color-coded by range. + +### Project Artifact Purge + +Clean old build artifacts (`node_modules`, `target`, `build`, `dist`, etc.) from your projects to free up disk space. + +```powershell +mole purge +``` + +``` +Select Categories to Clean - 18.5GB (8 selected) + +➤ ● my-react-app 3.2GB | node_modules + ● old-project 2.8GB | node_modules + ● rust-app 4.1GB | target + ● next-blog 1.9GB | node_modules + ○ current-work 856MB | node_modules | Recent + ● django-api 2.3GB | venv + ● vue-dashboard 1.7GB | node_modules + ● backend-service 2.5GB | node_modules +``` + +Use with caution: This will permanently delete selected artifacts. Review carefully before confirming. Recent projects — less than 7 days old — are marked and unselected by default. + +Custom scan paths can be configured with `mole purge -Paths`. + +## Installation Options + ### Manual Installation ```powershell @@ -37,51 +250,19 @@ cd Mole/windows .\install.ps1 -Uninstall ``` -## Usage +## Configuration -```powershell -# Interactive menu -mole +Mole stores its configuration in: -# Show help -mole -ShowHelp - -# Show version -mole -Version - -# Commands -mole clean # Deep system cleanup -mole clean -DryRun # Preview cleanup without deleting -mole uninstall # Interactive app uninstaller -mole optimize # System optimization -mole purge # Clean developer artifacts -mole analyze # Disk space analyzer -mole status # System health monitor -``` - -## Commands - -| Command | Description | -|---------|-------------| -| `clean` | Deep cleanup of temp files, caches, and logs | -| `uninstall` | Interactive application uninstaller | -| `optimize` | System optimization and health checks | -| `purge` | Clean project build artifacts (node_modules, etc.) | -| `analyze` | Interactive disk space analyzer (TUI) | -| `status` | Real-time system health monitor (TUI) | - -## Environment Variables - -| Variable | Description | -|----------|-------------| -| `MOLE_DRY_RUN=1` | Preview changes without making them | -| `MOLE_DEBUG=1` | Enable debug output | -| `MO_ANALYZE_PATH` | Starting path for analyze tool | +- Config: `~\.config\mole\` +- Cache: `~\.cache\mole\` +- Whitelist: `~\.config\mole\whitelist.txt` +- Purge paths: `~\.config\mole\purge_paths.txt` ## Directory Structure ``` -windows/ +mole/ (windows branch) ├── mole.ps1 # Main CLI entry point ├── install.ps1 # Windows installer ├── Makefile # Build automation for Go tools @@ -119,7 +300,7 @@ windows/ The analyze and status commands require Go to be installed: ```powershell -cd windows +# From the repository root # Build both tools make build @@ -131,39 +312,20 @@ go build -o bin/status.exe ./cmd/status/ # The wrapper scripts will auto-build if Go is available ``` -## Configuration +## Support -Mole stores its configuration in: -- Config: `~\.config\mole\` -- Cache: `~\.cache\mole\` -- Whitelist: `~\.config\mole\whitelist.txt` -- Purge paths: `~\.config\mole\purge_paths.txt` +- If Mole saved you disk space, consider starring the repo or [sharing it](https://twitter.com/intent/tweet?url=https://github.com/tw93/Mole/tree/windows&text=Mole%20-%20Deep%20clean%20and%20optimize%20your%20Windows%20PC.) with friends. +- Have ideas or fixes? Check our [Contributing Guide](https://github.com/tw93/Mole/blob/windows/CONTRIBUTING.md), then open an issue or PR to help shape Mole's future. +- Love Mole? [Buy Tw93 an ice-cold Coke](https://miaoyan.app/cats.html?name=Mole) to keep the project alive and kicking! 🥤 -## Development Phases +## Community Love -### Phase 1: Core Infrastructure ✅ -- [x] `install.ps1` - Windows installer -- [x] `mole.ps1` - Main CLI entry point -- [x] `lib/core/*` - Core utility libraries +Mole wouldn't be possible without these amazing contributors. They've built countless features that make Mole what it is today. Go follow them! ❤️ -### Phase 2: Cleanup Features ✅ -- [x] `bin/clean.ps1` - Deep cleanup orchestrator -- [x] `bin/uninstall.ps1` - App removal with leftover detection -- [x] `bin/optimize.ps1` - System optimization -- [x] `bin/purge.ps1` - Project artifact cleanup -- [x] `lib/clean/*` - Cleanup modules +[![Contributors](https://contrib.rocks/image?repo=tw93/Mole)](https://github.com/tw93/Mole/graphs/contributors) -### Phase 3: TUI Tools ✅ -- [x] `cmd/analyze/` - Disk usage analyzer (Go) -- [x] `cmd/status/` - Real-time system monitor (Go) -- [x] `bin/analyze.ps1` - Analyzer wrapper -- [x] `bin/status.ps1` - Status wrapper - -### Phase 4: Testing & CI (Planned) -- [ ] `tests/` - Pester tests -- [ ] GitHub Actions workflows -- [ ] `scripts/build.ps1` - Build automation +Join thousands of users worldwide who trust Mole to keep their systems clean and optimized. ## License -Same license as the main Mole project. +MIT License — feel free to enjoy and participate in open source. From 8b3def7ffe90ae34ec02dbc5e31936c183373c48 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 12 Jan 2026 14:29:15 +0000 Subject: [PATCH 06/10] chore: update contributors [skip ci] --- CONTRIBUTORS.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.svg b/CONTRIBUTORS.svg index 9a17f16..7c22074 100644 --- a/CONTRIBUTORS.svg +++ b/CONTRIBUTORS.svg @@ -1,4 +1,4 @@ - + From 3dccf3592f016088262fbb5060dd8732e648db21 Mon Sep 17 00:00:00 2001 From: Bhadra Date: Mon, 12 Jan 2026 20:23:51 +0530 Subject: [PATCH 07/10] feat: add game media cleanup (replays, screenshots, recordings) - Add Clear-GameMediaFiles function to clean old game media (>90d by default) - Supports NVIDIA ShadowPlay/Highlights, AMD ReLive, Xbox Game Bar - Supports Steam screenshots, OBS recordings, Medal.tv, Overwolf/Outplayed - Includes game-specific replays (Fortnite, LoL, Valorant, Rocket League, etc.) - New -GameMedia flag for mole clean command - Uses age-based cleanup to protect recent recordings --- bin/clean.ps1 | 23 +++-- lib/clean/apps.ps1 | 244 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 259 insertions(+), 8 deletions(-) diff --git a/bin/clean.ps1 b/bin/clean.ps1 index 4e07f1f..6220a5b 100644 --- a/bin/clean.ps1 +++ b/bin/clean.ps1 @@ -6,6 +6,7 @@ param( [switch]$DryRun, [switch]$System, + [switch]$GameMedia, [switch]$DebugMode, [switch]$Whitelist, [switch]$ShowHelp @@ -51,14 +52,16 @@ function Show-CleanHelp { Write-Host "$esc[33mOptions:$esc[0m" Write-Host " -DryRun Preview changes without deleting (recommended first run)" Write-Host " -System Include system-level cleanup (requires admin)" + Write-Host " -GameMedia Clean old game replays, screenshots, recordings (>90d)" Write-Host " -Whitelist Manage protected paths" Write-Host " -DebugMode Enable debug logging" Write-Host " -ShowHelp Show this help message" Write-Host "" Write-Host "$esc[33mExamples:$esc[0m" - Write-Host " mole clean -DryRun # Preview what would be cleaned" - Write-Host " mole clean # Run standard cleanup" - Write-Host " mole clean -System # Include system cleanup (as admin)" + Write-Host " mole clean -DryRun # Preview what would be cleaned" + Write-Host " mole clean # Run standard cleanup" + Write-Host " mole clean -GameMedia # Include old game media cleanup" + Write-Host " mole clean -System # Include system cleanup (as admin)" Write-Host "" } @@ -161,7 +164,8 @@ function Show-CleanupSummary { function Start-Cleanup { param( [bool]$IsDryRun, - [bool]$IncludeSystem + [bool]$IncludeSystem, + [bool]$IncludeGameMedia ) $esc = [char]27 @@ -239,8 +243,13 @@ function Start-Cleanup { # Developer tools Invoke-DevToolsCleanup - # Applications cleanup - Invoke-AppCleanup + # Applications cleanup (with optional game media) + if ($IncludeGameMedia) { + Invoke-AppCleanup -IncludeGameMedia -GameMediaDaysOld 90 + } + else { + Invoke-AppCleanup + } # System cleanup (if requested and admin) if ($IncludeSystem -and (Test-IsAdmin)) { @@ -291,7 +300,7 @@ function Main { # Run cleanup try { - Start-Cleanup -IsDryRun $DryRun -IncludeSystem $System + Start-Cleanup -IsDryRun $DryRun -IncludeSystem $System -IncludeGameMedia $GameMedia } finally { # Cleanup temp files diff --git a/lib/clean/apps.ps1 b/lib/clean/apps.ps1 index 36ed9c7..4a52199 100644 --- a/lib/clean/apps.ps1 +++ b/lib/clean/apps.ps1 @@ -402,6 +402,239 @@ function Clear-GamingPlatformCaches { } } +# ============================================================================ +# Game Media Cleanup (Replays, Screenshots, Recordings) +# ============================================================================ + +function Clear-GameMediaFiles { + <# + .SYNOPSIS + Clean old game replays, screenshots, and recordings + .DESCRIPTION + Removes old media files from various gaming sources: + - NVIDIA ShadowPlay/Highlights + - AMD ReLive + - Xbox Game Bar captures + - Steam screenshots + - OBS recordings + - Windows Game DVR + - GeForce Experience + + By default, only removes files older than 90 days. + User media in standard Pictures/Videos folders is NOT touched + unless it's in a game-specific subfolder. + .PARAMETER DaysOld + Minimum age of files to remove (default: 90 days) + #> + param( + [int]$DaysOld = 90 + ) + + Start-Section "Game media (>${DaysOld}d old)" + + $cutoffDate = (Get-Date).AddDays(-$DaysOld) + $mediaExtensions = @('*.mp4', '*.mkv', '*.avi', '*.mov', '*.wmv', '*.webm', '*.png', '*.jpg', '*.jpeg', '*.bmp', '*.gif') + + # ------------------------------------------------------------------------- + # NVIDIA ShadowPlay / GeForce Experience + # ------------------------------------------------------------------------- + $nvidiaPaths = @( + "$env:USERPROFILE\Videos\NVIDIA" # Default ShadowPlay location + "$env:USERPROFILE\Videos\ShadowPlay" # Alternative name + "$env:USERPROFILE\Videos\GeForce Experience" # GeForce Experience recordings + ) + + foreach ($basePath in $nvidiaPaths) { + if (Test-Path $basePath) { + foreach ($ext in $mediaExtensions) { + $oldFiles = Get-ChildItem -Path $basePath -Filter $ext -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "NVIDIA recordings (>${DaysOld}d)" + } + } + } + } + + # NVIDIA Highlights (game-specific clips) + $highlightsPath = "$env:USERPROFILE\Videos\NVIDIA\Highlights" + if (Test-Path $highlightsPath) { + $oldHighlights = Get-ChildItem -Path $highlightsPath -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate -and $_.Extension -match '\.(mp4|mkv|avi|mov)$' } + if ($oldHighlights) { + $paths = $oldHighlights | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "NVIDIA Highlights (>${DaysOld}d)" + } + } + + # ------------------------------------------------------------------------- + # AMD ReLive / Radeon Software + # ------------------------------------------------------------------------- + $amdPaths = @( + "$env:USERPROFILE\Videos\Radeon ReLive" + "$env:USERPROFILE\Videos\AMD" + "$env:USERPROFILE\Videos\Radeon" + ) + + foreach ($basePath in $amdPaths) { + if (Test-Path $basePath) { + foreach ($ext in $mediaExtensions) { + $oldFiles = Get-ChildItem -Path $basePath -Filter $ext -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "AMD ReLive recordings (>${DaysOld}d)" + } + } + } + } + + # ------------------------------------------------------------------------- + # Xbox Game Bar / Windows Game DVR + # ------------------------------------------------------------------------- + $xboxCapturesPath = "$env:USERPROFILE\Videos\Captures" + if (Test-Path $xboxCapturesPath) { + foreach ($ext in $mediaExtensions) { + $oldFiles = Get-ChildItem -Path $xboxCapturesPath -Filter $ext -File -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "Xbox Game Bar captures (>${DaysOld}d)" + } + } + } + + # ------------------------------------------------------------------------- + # Steam Screenshots + # ------------------------------------------------------------------------- + # Steam stores screenshots in userdata\\760\remote\\screenshots + $steamUserDataPath = "${env:ProgramFiles(x86)}\Steam\userdata" + if (Test-Path $steamUserDataPath) { + $screenshotFolders = Get-ChildItem -Path $steamUserDataPath -Directory -ErrorAction SilentlyContinue | + ForEach-Object { Join-Path $_.FullName "760\remote" } | + Where-Object { Test-Path $_ } + + foreach ($folder in $screenshotFolders) { + $oldScreenshots = Get-ChildItem -Path $folder -Filter "*.jpg" -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldScreenshots) { + $paths = $oldScreenshots | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "Steam screenshots (>${DaysOld}d)" + } + } + } + + # Also check common Steam screenshot export location + $steamScreenshotsPath = "$env:USERPROFILE\Pictures\Steam Screenshots" + if (Test-Path $steamScreenshotsPath) { + $oldFiles = Get-ChildItem -Path $steamScreenshotsPath -Filter "*.jpg" -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "Steam exported screenshots (>${DaysOld}d)" + } + } + + # ------------------------------------------------------------------------- + # OBS Studio Recordings + # ------------------------------------------------------------------------- + $obsRecordingsPath = "$env:USERPROFILE\Videos\OBS" + if (Test-Path $obsRecordingsPath) { + foreach ($ext in @('*.mp4', '*.mkv', '*.flv', '*.mov', '*.ts')) { + $oldFiles = Get-ChildItem -Path $obsRecordingsPath -Filter $ext -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "OBS recordings (>${DaysOld}d)" + } + } + } + + # ------------------------------------------------------------------------- + # Windows Game DVR (legacy location) + # ------------------------------------------------------------------------- + $gameDvrPath = "$env:LOCALAPPDATA\Packages\Microsoft.XboxGamingOverlay_*\LocalState\GameDVR" + $gameDvrPaths = Resolve-Path $gameDvrPath -ErrorAction SilentlyContinue + foreach ($path in $gameDvrPaths) { + if (Test-Path $path.Path) { + $oldFiles = Get-ChildItem -Path $path.Path -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate -and $_.Extension -match '\.(mp4|png)$' } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "Game DVR recordings (>${DaysOld}d)" + } + } + } + + # ------------------------------------------------------------------------- + # Medal.tv Clips + # ------------------------------------------------------------------------- + $medalPath = "$env:USERPROFILE\Videos\Medal" + if (Test-Path $medalPath) { + foreach ($ext in $mediaExtensions) { + $oldFiles = Get-ChildItem -Path $medalPath -Filter $ext -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "Medal.tv clips (>${DaysOld}d)" + } + } + } + + # ------------------------------------------------------------------------- + # Overwolf / Outplayed Recordings + # ------------------------------------------------------------------------- + $overwolfPaths = @( + "$env:USERPROFILE\Videos\Overwolf" + "$env:USERPROFILE\Videos\Outplayed" + ) + foreach ($basePath in $overwolfPaths) { + if (Test-Path $basePath) { + foreach ($ext in $mediaExtensions) { + $oldFiles = Get-ChildItem -Path $basePath -Filter $ext -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "Overwolf/Outplayed recordings (>${DaysOld}d)" + } + } + } + } + + # ------------------------------------------------------------------------- + # Game-specific replay folders (common locations) + # ------------------------------------------------------------------------- + $gameReplayPaths = @( + # Fortnite replays + "$env:LOCALAPPDATA\FortniteGame\Saved\Demos" + # League of Legends replays + "$env:USERPROFILE\Documents\League of Legends\Replays" + # Valorant + "$env:LOCALAPPDATA\VALORANT\Saved\Logs" + # Rocket League replays + "$env:USERPROFILE\Documents\My Games\Rocket League\TAGame\Demos" + # Call of Duty + "$env:USERPROFILE\Documents\Call of Duty\players\theatre" + # Apex Legends + "$env:USERPROFILE\Saved Games\Respawn\Apex\assets\temp" + ) + + foreach ($path in $gameReplayPaths) { + if (Test-Path $path) { + $oldFiles = Get-ChildItem -Path $path -File -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $gameName = (Split-Path (Split-Path $path -Parent) -Leaf) + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "$gameName replays (>${DaysOld}d)" + } + } + } + + Stop-Section +} + # ============================================================================ # Main Application Cleanup Function # ============================================================================ @@ -411,7 +644,11 @@ function Invoke-AppCleanup { .SYNOPSIS Run all application-specific cleanup tasks #> - param([switch]$IncludeOrphaned) + param( + [switch]$IncludeOrphaned, + [switch]$IncludeGameMedia, + [int]$GameMediaDaysOld = 90 + ) Start-Section "Applications" @@ -430,6 +667,11 @@ function Invoke-AppCleanup { Stop-Section + # Game media (replays, screenshots, recordings) + if ($IncludeGameMedia) { + Clear-GameMediaFiles -DaysOld $GameMediaDaysOld + } + # Orphaned app data (separate section) if ($IncludeOrphaned) { Clear-OrphanedAppData -DaysOld 60 From ba8ec9ef3467d9301c3193b08094768982a4c65c Mon Sep 17 00:00:00 2001 From: Bhadra Date: Mon, 12 Jan 2026 20:48:33 +0530 Subject: [PATCH 08/10] feat: add Windows screenshots and screen recordings cleanup - Add Pictures\Screenshots path (Snipping Tool/Snip & Sketch) - Add Videos\Screen Recordings path (Windows 11 screen recorder) - Both use age-based cleanup (>90d by default) --- lib/clean/apps.ps1 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/clean/apps.ps1 b/lib/clean/apps.ps1 index 4a52199..eb36e1e 100644 --- a/lib/clean/apps.ps1 +++ b/lib/clean/apps.ps1 @@ -505,6 +505,36 @@ function Clear-GameMediaFiles { } } + # ------------------------------------------------------------------------- + # Windows Snipping Tool / Snip & Sketch Screenshots + # ------------------------------------------------------------------------- + $windowsScreenshotsPath = "$env:USERPROFILE\Pictures\Screenshots" + if (Test-Path $windowsScreenshotsPath) { + foreach ($ext in @('*.png', '*.jpg', '*.jpeg', '*.gif', '*.bmp')) { + $oldFiles = Get-ChildItem -Path $windowsScreenshotsPath -Filter $ext -File -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "Windows screenshots (>${DaysOld}d)" + } + } + } + + # ------------------------------------------------------------------------- + # Windows Screen Recordings (Snipping Tool / Win+Alt+R) + # ------------------------------------------------------------------------- + $windowsRecordingsPath = "$env:USERPROFILE\Videos\Screen Recordings" + if (Test-Path $windowsRecordingsPath) { + foreach ($ext in @('*.mp4', '*.mkv', '*.avi', '*.mov', '*.wmv')) { + $oldFiles = Get-ChildItem -Path $windowsRecordingsPath -Filter $ext -File -ErrorAction SilentlyContinue | + Where-Object { $_.LastWriteTime -lt $cutoffDate } + if ($oldFiles) { + $paths = $oldFiles | ForEach-Object { $_.FullName } + Remove-SafeItems -Paths $paths -Description "Windows screen recordings (>${DaysOld}d)" + } + } + } + # ------------------------------------------------------------------------- # Steam Screenshots # ------------------------------------------------------------------------- From 56434486faa1b61c76a08486b4271599c39df2bc Mon Sep 17 00:00:00 2001 From: Bhadra Date: Wed, 14 Jan 2026 09:23:25 +0530 Subject: [PATCH 09/10] refactor: merge repair command into optimize Per tw93's feedback on PR #305, consolidate repair utilities into the optimize command to keep the CLI simple and unified. Changes: - Add repair flags to optimize: -Repair, -Font, -Icon, -Search, -Store - Remove standalone repair.ps1 command - Update mole.ps1 menu and help to reflect changes - optimize now handles both optimization and repair tasks Usage: mole optimize # Standard optimizations mole optimize -Repair # Optimizations + all repairs mole optimize -Icon -Font # Optimizations + specific repairs --- bin/optimize.ps1 | 302 ++++++++++++++++++++++++++++- bin/repair.ps1 | 491 ----------------------------------------------- mole.ps1 | 31 ++- 3 files changed, 304 insertions(+), 520 deletions(-) delete mode 100644 bin/repair.ps1 diff --git a/bin/optimize.ps1 b/bin/optimize.ps1 index 5973ee9..7c52361 100644 --- a/bin/optimize.ps1 +++ b/bin/optimize.ps1 @@ -1,12 +1,18 @@ # Mole - Optimize Command -# System optimization and health checks for Windows +# System optimization, health checks, and repairs for Windows #Requires -Version 5.1 [CmdletBinding()] param( [switch]$DryRun, [switch]$DebugMode, - [switch]$ShowHelp + [switch]$ShowHelp, + # Repair options + [switch]$Repair, + [switch]$Font, + [switch]$Icon, + [switch]$Search, + [switch]$Store ) Set-StrictMode -Version Latest @@ -27,6 +33,7 @@ $libDir = Join-Path (Split-Path -Parent $scriptDir) "lib" # ============================================================================ $script:OptimizationsApplied = 0 +$script:RepairsApplied = 0 $script:IssuesFound = 0 $script:IssuesFixed = 0 @@ -37,22 +44,36 @@ $script:IssuesFixed = 0 function Show-OptimizeHelp { $esc = [char]27 Write-Host "" - Write-Host "$esc[1;35mMole Optimize$esc[0m - System optimization and health checks" + Write-Host "$esc[1;35mMole Optimize$esc[0m - System optimization, health checks, and repairs" Write-Host "" Write-Host "$esc[33mUsage:$esc[0m mole optimize [options]" Write-Host "" Write-Host "$esc[33mOptions:$esc[0m" - Write-Host " -DryRun Preview optimizations without applying" + Write-Host " -DryRun Preview changes without applying" Write-Host " -DebugMode Enable debug logging" Write-Host " -ShowHelp Show this help message" Write-Host "" - Write-Host "$esc[33mOptimizations:$esc[0m" + Write-Host "$esc[33mRepair Options:$esc[0m" + Write-Host " -Repair Run all repairs (Font, Icon, Search, Store)" + Write-Host " -Font Rebuild font cache (fixes font display issues)" + Write-Host " -Icon Rebuild icon cache (fixes missing/corrupt icons)" + Write-Host " -Search Reset Windows Search index (fixes search issues)" + Write-Host " -Store Reset Windows Store cache (fixes Store issues)" + Write-Host "" + Write-Host "$esc[33mExamples:$esc[0m" + Write-Host " mole optimize # Run standard optimizations" + Write-Host " mole optimize -Repair # Run optimizations + all repairs" + Write-Host " mole optimize -Icon -Font # Run optimizations + specific repairs" + Write-Host " mole optimize -DryRun # Preview what would happen" + Write-Host "" + Write-Host "$esc[33mOptimizations (always run):$esc[0m" Write-Host " - Disk defragmentation/TRIM (SSD optimization)" - Write-Host " - Windows Search index optimization" + Write-Host " - Windows Search index check" Write-Host " - DNS cache flush" Write-Host " - Network optimization" Write-Host " - Startup program analysis" - Write-Host " - System file verification" + Write-Host " - Disk health check" + Write-Host " - Windows Update status" Write-Host "" } @@ -440,6 +461,234 @@ function Test-WindowsUpdate { } } +# ============================================================================ +# Repair Functions +# ============================================================================ + +function Repair-FontCache { + <# + .SYNOPSIS + Rebuild Windows font cache + .DESCRIPTION + Stops the font cache service, clears the cache files, and restarts. + Fixes issues with fonts not displaying correctly or missing fonts. + #> + + $esc = [char]27 + + Write-Host "" + Write-Host "$esc[34m$($script:Icons.Arrow) Font Cache Rebuild$esc[0m" + + if (-not (Test-IsAdmin)) { + Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Requires administrator privileges" + return + } + + # Font cache locations + $fontCachePaths = @( + "$env:LOCALAPPDATA\Microsoft\Windows\Fonts" + "$env:WINDIR\ServiceProfiles\LocalService\AppData\Local\FontCache" + "$env:WINDIR\System32\FNTCACHE.DAT" + ) + + if ($script:DryRun) { + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Windows Font Cache Service" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete font cache files" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Windows Font Cache Service" + $script:RepairsApplied++ + return + } + + try { + # Stop font cache service + Write-Host " $esc[90mStopping Font Cache Service...$esc[0m" + Stop-Service -Name "FontCache" -Force -ErrorAction SilentlyContinue + Stop-Service -Name "FontCache3.0.0.0" -Force -ErrorAction SilentlyContinue + + # Wait a moment for service to stop + Start-Sleep -Seconds 2 + + # Delete font cache files + foreach ($path in $fontCachePaths) { + if (Test-Path $path) { + if (Test-Path $path -PathType Container) { + Get-ChildItem -Path $path -Recurse -Force -ErrorAction SilentlyContinue | + Remove-Item -Force -Recurse -ErrorAction SilentlyContinue + } + else { + Remove-Item -Path $path -Force -ErrorAction SilentlyContinue + } + } + } + + # Restart font cache service + Write-Host " $esc[90mRestarting Font Cache Service...$esc[0m" + Start-Service -Name "FontCache" -ErrorAction SilentlyContinue + Start-Service -Name "FontCache3.0.0.0" -ErrorAction SilentlyContinue + + Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Font cache rebuilt successfully" + Write-Host " $esc[90mNote: Some apps may need restart to see changes$esc[0m" + $script:RepairsApplied++ + } + catch { + Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not rebuild font cache: $_" + Start-Service -Name "FontCache" -ErrorAction SilentlyContinue + } +} + +function Repair-IconCache { + <# + .SYNOPSIS + Rebuild Windows icon cache + .DESCRIPTION + Clears the icon cache database files, forcing Windows to rebuild them. + Fixes issues with missing, corrupted, or outdated icons. + #> + + $esc = [char]27 + + Write-Host "" + Write-Host "$esc[34m$($script:Icons.Arrow) Icon Cache Rebuild$esc[0m" + + $iconCachePath = "$env:LOCALAPPDATA\Microsoft\Windows\Explorer" + + if ($script:DryRun) { + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Explorer" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete icon cache files (iconcache_*.db)" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Explorer" + $script:RepairsApplied++ + return + } + + try { + Write-Host " $esc[90mStopping Explorer...$esc[0m" + Stop-Process -Name "explorer" -Force -ErrorAction SilentlyContinue + Start-Sleep -Seconds 2 + + # Delete icon cache files + $iconCacheFiles = Get-ChildItem -Path $iconCachePath -Filter "iconcache_*.db" -Force -ErrorAction SilentlyContinue + $thumbCacheFiles = Get-ChildItem -Path $iconCachePath -Filter "thumbcache_*.db" -Force -ErrorAction SilentlyContinue + + $deletedCount = 0 + foreach ($file in $iconCacheFiles) { + Remove-Item -Path $file.FullName -Force -ErrorAction SilentlyContinue + $deletedCount++ + } + + foreach ($file in $thumbCacheFiles) { + Remove-Item -Path $file.FullName -Force -ErrorAction SilentlyContinue + $deletedCount++ + } + + $systemIconCache = "$env:LOCALAPPDATA\IconCache.db" + if (Test-Path $systemIconCache) { + Remove-Item -Path $systemIconCache -Force -ErrorAction SilentlyContinue + $deletedCount++ + } + + Write-Host " $esc[90mRestarting Explorer...$esc[0m" + Start-Process "explorer.exe" + + Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Icon cache rebuilt ($deletedCount files cleared)" + Write-Host " $esc[90mNote: Icons will rebuild gradually as you browse$esc[0m" + $script:RepairsApplied++ + } + catch { + Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not rebuild icon cache: $_" + Start-Process "explorer.exe" -ErrorAction SilentlyContinue + } +} + +function Repair-SearchIndex { + <# + .SYNOPSIS + Reset Windows Search index + .DESCRIPTION + Stops the Windows Search service, deletes the search index, and restarts. + Fixes issues with search not finding files or returning incorrect results. + #> + + $esc = [char]27 + + Write-Host "" + Write-Host "$esc[34m$($script:Icons.Arrow) Windows Search Index Reset$esc[0m" + + if (-not (Test-IsAdmin)) { + Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Requires administrator privileges" + return + } + + $searchIndexPath = "$env:ProgramData\Microsoft\Search\Data\Applications\Windows" + + if ($script:DryRun) { + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Windows Search service" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete search index database" + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Windows Search service" + $script:RepairsApplied++ + return + } + + try { + Write-Host " $esc[90mStopping Windows Search service...$esc[0m" + Stop-Service -Name "WSearch" -Force -ErrorAction Stop + Start-Sleep -Seconds 3 + + if (Test-Path $searchIndexPath) { + Write-Host " $esc[90mDeleting search index...$esc[0m" + Remove-Item -Path "$searchIndexPath\*" -Recurse -Force -ErrorAction SilentlyContinue + } + + Write-Host " $esc[90mRestarting Windows Search service...$esc[0m" + Start-Service -Name "WSearch" -ErrorAction Stop + + Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Search index reset successfully" + Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Indexing will rebuild in the background (may take hours)" + $script:RepairsApplied++ + } + catch { + Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not reset search index: $_" + Start-Service -Name "WSearch" -ErrorAction SilentlyContinue + } +} + +function Repair-StoreCache { + <# + .SYNOPSIS + Reset Windows Store cache + .DESCRIPTION + Runs wsreset.exe to clear the Windows Store cache. + Fixes issues with Store apps not installing, updating, or launching. + #> + + $esc = [char]27 + + Write-Host "" + Write-Host "$esc[34m$($script:Icons.Arrow) Windows Store Cache Reset$esc[0m" + + if ($script:DryRun) { + Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would run wsreset.exe" + $script:RepairsApplied++ + return + } + + try { + Write-Host " $esc[90mResetting Windows Store cache...$esc[0m" + $wsreset = Start-Process -FilePath "wsreset.exe" -PassThru -WindowStyle Hidden + $wsreset.WaitForExit(30000) + + if ($wsreset.ExitCode -eq 0) { + Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Windows Store cache reset successfully" + } + else { + Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m wsreset completed with code $($wsreset.ExitCode)" + } + $script:RepairsApplied++ + } + catch { + Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not reset Store cache: $_" + } +} + # ============================================================================ # Summary # ============================================================================ @@ -459,12 +708,20 @@ function Show-OptimizeSummary { Write-Host "" if ($script:DryRun) { - Write-Host " Would apply $esc[33m$($script:OptimizationsApplied)$esc[0m optimizations" + $total = $script:OptimizationsApplied + $script:RepairsApplied + Write-Host " Would apply $esc[33m$total$esc[0m changes" + if ($script:RepairsApplied -gt 0) { + Write-Host " ($($script:OptimizationsApplied) optimizations, $($script:RepairsApplied) repairs)" + } Write-Host " Run without -DryRun to apply changes" } else { Write-Host " Optimizations applied: $esc[32m$($script:OptimizationsApplied)$esc[0m" + if ($script:RepairsApplied -gt 0) { + Write-Host " Repairs applied: $esc[32m$($script:RepairsApplied)$esc[0m" + } + if ($script:IssuesFixed -gt 0) { Write-Host " Issues fixed: $esc[32m$($script:IssuesFixed)$esc[0m" } @@ -500,6 +757,9 @@ function Main { # Set dry-run mode $script:DryRun = $DryRun + # Check if any repairs were requested + $runRepairs = $Repair -or $Font -or $Icon -or $Search -or $Store + # Clear screen Clear-Host @@ -528,8 +788,30 @@ function Main { Test-DiskHealth Test-WindowsUpdate - # System file check is slow, ask first - if (-not $script:DryRun -and (Test-IsAdmin)) { + # Run repairs if requested + if ($runRepairs) { + Write-Host "" + Write-Host "$esc[1;35m$($script:Icons.Arrow) Repairs$esc[0m" + + if ($Repair -or $Font) { + Repair-FontCache + } + + if ($Repair -or $Icon) { + Repair-IconCache + } + + if ($Repair -or $Search) { + Repair-SearchIndex + } + + if ($Repair -or $Store) { + Repair-StoreCache + } + } + + # System file check is slow, ask first (only if not doing repairs) + if (-not $runRepairs -and -not $script:DryRun -and (Test-IsAdmin)) { Write-Host "" $runSfc = Read-Host "Run System File Checker? This may take several minutes (y/N)" if ($runSfc -eq 'y' -or $runSfc -eq 'Y') { diff --git a/bin/repair.ps1 b/bin/repair.ps1 deleted file mode 100644 index 1942a75..0000000 --- a/bin/repair.ps1 +++ /dev/null @@ -1,491 +0,0 @@ -# Mole - Repair Command -# System repair utilities for Windows (cache rebuilds, resets) - -#Requires -Version 5.1 -[CmdletBinding()] -param( - [switch]$DryRun, - [switch]$DebugMode, - [switch]$ShowHelp, - [switch]$All, - [switch]$DNS, - [switch]$Font, - [switch]$Icon, - [switch]$Search, - [switch]$Store -) - -Set-StrictMode -Version Latest -$ErrorActionPreference = "Stop" - -# Script location -$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path -$libDir = Join-Path (Split-Path -Parent $scriptDir) "lib" - -# Import core modules -. "$libDir\core\base.ps1" -. "$libDir\core\log.ps1" -. "$libDir\core\ui.ps1" - -# ============================================================================ -# Configuration -# ============================================================================ - -$script:RepairsApplied = 0 -$script:IsDryRun = $DryRun -or ($env:MOLE_DRY_RUN -eq "1") - -# ============================================================================ -# Help -# ============================================================================ - -function Show-RepairHelp { - $esc = [char]27 - Write-Host "" - Write-Host "$esc[1;35mMole Repair$esc[0m - System repair utilities" - Write-Host "" - Write-Host "$esc[33mUsage:$esc[0m mole repair [options]" - Write-Host "" - Write-Host "$esc[33mOptions:$esc[0m" - Write-Host " -All Run all repairs" - Write-Host " -DNS Flush DNS cache" - Write-Host " -Font Rebuild font cache" - Write-Host " -Icon Rebuild icon cache" - Write-Host " -Search Reset Windows Search index" - Write-Host " -Store Reset Windows Store cache" - Write-Host "" - Write-Host " -DryRun Preview repairs without applying" - Write-Host " -DebugMode Enable debug logging" - Write-Host " -ShowHelp Show this help message" - Write-Host "" - Write-Host "$esc[33mExamples:$esc[0m" - Write-Host " mole repair -DNS Flush DNS cache" - Write-Host " mole repair -Icon -Font Rebuild icon and font caches" - Write-Host " mole repair -All Run all repairs" - Write-Host "" -} - -# ============================================================================ -# Repair Functions -# ============================================================================ - -function Repair-DnsCache { - <# - .SYNOPSIS - Flush DNS resolver cache - .DESCRIPTION - Clears the DNS client cache, forcing fresh DNS lookups. - Useful when DNS records have changed or you're having connectivity issues. - #> - - $esc = [char]27 - - Write-Host "" - Write-Host "$esc[34m$($script:Icons.Arrow) DNS Cache Flush$esc[0m" - - if ($script:IsDryRun) { - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would flush DNS cache" - $script:RepairsApplied++ - return - } - - try { - Clear-DnsClientCache -ErrorAction Stop - Write-Host " $esc[32m$($script:Icons.Success)$esc[0m DNS cache flushed successfully" - $script:RepairsApplied++ - } - catch { - Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not flush DNS cache: $_" - } -} - -function Repair-FontCache { - <# - .SYNOPSIS - Rebuild Windows font cache - .DESCRIPTION - Stops the font cache service, clears the cache files, and restarts. - Fixes issues with fonts not displaying correctly or missing fonts. - #> - - $esc = [char]27 - - Write-Host "" - Write-Host "$esc[34m$($script:Icons.Arrow) Font Cache Rebuild$esc[0m" - - if (-not (Test-IsAdmin)) { - Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Requires administrator privileges" - return - } - - # Font cache locations - $fontCachePaths = @( - "$env:LOCALAPPDATA\Microsoft\Windows\Fonts" - "$env:WINDIR\ServiceProfiles\LocalService\AppData\Local\FontCache" - "$env:WINDIR\System32\FNTCACHE.DAT" - ) - - if ($script:IsDryRun) { - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Windows Font Cache Service" - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete font cache files" - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Windows Font Cache Service" - $script:RepairsApplied++ - return - } - - try { - # Stop font cache service - Write-Host " $esc[90mStopping Font Cache Service...$esc[0m" - Stop-Service -Name "FontCache" -Force -ErrorAction SilentlyContinue - Stop-Service -Name "FontCache3.0.0.0" -Force -ErrorAction SilentlyContinue - - # Wait a moment for service to stop - Start-Sleep -Seconds 2 - - # Delete font cache files - foreach ($path in $fontCachePaths) { - if (Test-Path $path) { - if (Test-Path $path -PathType Container) { - # Directory - clear contents - Get-ChildItem -Path $path -Recurse -Force -ErrorAction SilentlyContinue | - Remove-Item -Force -Recurse -ErrorAction SilentlyContinue - } - else { - # File - delete it - Remove-Item -Path $path -Force -ErrorAction SilentlyContinue - } - } - } - - # Restart font cache service - Write-Host " $esc[90mRestarting Font Cache Service...$esc[0m" - Start-Service -Name "FontCache" -ErrorAction SilentlyContinue - Start-Service -Name "FontCache3.0.0.0" -ErrorAction SilentlyContinue - - Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Font cache rebuilt successfully" - Write-Host " $esc[90mNote: Some apps may need restart to see changes$esc[0m" - $script:RepairsApplied++ - } - catch { - Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not rebuild font cache: $_" - # Try to restart services even if we failed - Start-Service -Name "FontCache" -ErrorAction SilentlyContinue - } -} - -function Repair-IconCache { - <# - .SYNOPSIS - Rebuild Windows icon cache - .DESCRIPTION - Clears the icon cache database files, forcing Windows to rebuild them. - Fixes issues with missing, corrupted, or outdated icons. - #> - - $esc = [char]27 - - Write-Host "" - Write-Host "$esc[34m$($script:Icons.Arrow) Icon Cache Rebuild$esc[0m" - - # Icon cache locations - $iconCachePath = "$env:LOCALAPPDATA\Microsoft\Windows\Explorer" - $thumbCachePath = "$env:LOCALAPPDATA\Microsoft\Windows\Explorer" - - if ($script:IsDryRun) { - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Explorer" - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete icon cache files (iconcache_*.db)" - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Explorer" - $script:RepairsApplied++ - return - } - - try { - Write-Host " $esc[90mStopping Explorer...$esc[0m" - - # Kill explorer (will restart automatically, or we restart it) - Stop-Process -Name "explorer" -Force -ErrorAction SilentlyContinue - - # Wait for explorer to fully stop - Start-Sleep -Seconds 2 - - # Delete icon cache files - $iconCacheFiles = Get-ChildItem -Path $iconCachePath -Filter "iconcache_*.db" -Force -ErrorAction SilentlyContinue - $thumbCacheFiles = Get-ChildItem -Path $thumbCachePath -Filter "thumbcache_*.db" -Force -ErrorAction SilentlyContinue - - $deletedCount = 0 - foreach ($file in $iconCacheFiles) { - Remove-Item -Path $file.FullName -Force -ErrorAction SilentlyContinue - $deletedCount++ - } - - # Also clear thumbcache for good measure - foreach ($file in $thumbCacheFiles) { - Remove-Item -Path $file.FullName -Force -ErrorAction SilentlyContinue - $deletedCount++ - } - - # Also clear the system-wide icon cache - $systemIconCache = "$env:LOCALAPPDATA\IconCache.db" - if (Test-Path $systemIconCache) { - Remove-Item -Path $systemIconCache -Force -ErrorAction SilentlyContinue - $deletedCount++ - } - - Write-Host " $esc[90mRestarting Explorer...$esc[0m" - - # Restart explorer - Start-Process "explorer.exe" - - Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Icon cache rebuilt ($deletedCount files cleared)" - Write-Host " $esc[90mNote: Icons will rebuild gradually as you browse$esc[0m" - $script:RepairsApplied++ - } - catch { - Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not rebuild icon cache: $_" - # Make sure explorer is running - Start-Process "explorer.exe" -ErrorAction SilentlyContinue - } -} - -function Repair-SearchIndex { - <# - .SYNOPSIS - Reset Windows Search index - .DESCRIPTION - Stops the Windows Search service, deletes the search index, and restarts. - Fixes issues with search not finding files or returning incorrect results. - Note: Rebuilding the index can take hours depending on file count. - #> - - $esc = [char]27 - - Write-Host "" - Write-Host "$esc[34m$($script:Icons.Arrow) Windows Search Index Reset$esc[0m" - - if (-not (Test-IsAdmin)) { - Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Requires administrator privileges" - return - } - - $searchIndexPath = "$env:ProgramData\Microsoft\Search\Data\Applications\Windows" - - if ($script:IsDryRun) { - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Windows Search service" - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete search index database" - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Windows Search service" - $script:RepairsApplied++ - return - } - - try { - Write-Host " $esc[90mStopping Windows Search service...$esc[0m" - Stop-Service -Name "WSearch" -Force -ErrorAction Stop - - # Wait for service to fully stop - Start-Sleep -Seconds 3 - - # Delete search index - if (Test-Path $searchIndexPath) { - Write-Host " $esc[90mDeleting search index...$esc[0m" - Remove-Item -Path "$searchIndexPath\*" -Recurse -Force -ErrorAction SilentlyContinue - } - - Write-Host " $esc[90mRestarting Windows Search service...$esc[0m" - Start-Service -Name "WSearch" -ErrorAction Stop - - Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Search index reset successfully" - Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Indexing will rebuild in the background (may take hours)" - $script:RepairsApplied++ - } - catch { - Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not reset search index: $_" - # Try to restart service - Start-Service -Name "WSearch" -ErrorAction SilentlyContinue - } -} - -function Repair-StoreCache { - <# - .SYNOPSIS - Reset Windows Store cache - .DESCRIPTION - Runs wsreset.exe to clear the Windows Store cache. - Fixes issues with Store apps not installing, updating, or launching. - #> - - $esc = [char]27 - - Write-Host "" - Write-Host "$esc[34m$($script:Icons.Arrow) Windows Store Cache Reset$esc[0m" - - if ($script:IsDryRun) { - Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would run wsreset.exe" - $script:RepairsApplied++ - return - } - - try { - Write-Host " $esc[90mResetting Windows Store cache...$esc[0m" - - # wsreset.exe clears the store cache and reopens the Store - $wsreset = Start-Process -FilePath "wsreset.exe" -PassThru -WindowStyle Hidden - - # Wait for it to complete (usually quick) - $wsreset.WaitForExit(30000) # 30 second timeout - - if ($wsreset.ExitCode -eq 0) { - Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Windows Store cache reset successfully" - $script:RepairsApplied++ - } - else { - Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m wsreset completed with code $($wsreset.ExitCode)" - $script:RepairsApplied++ - } - } - catch { - Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not reset Store cache: $_" - } -} - -# ============================================================================ -# Interactive Menu -# ============================================================================ - -function Show-RepairMenu { - $esc = [char]27 - - $menuItems = @( - @{ Key = "1"; Label = "DNS Cache"; Desc = "Flush DNS resolver cache"; Action = { Repair-DnsCache } } - @{ Key = "2"; Label = "Font Cache"; Desc = "Rebuild font cache (Admin)"; Action = { Repair-FontCache } } - @{ Key = "3"; Label = "Icon Cache"; Desc = "Rebuild icon cache"; Action = { Repair-IconCache } } - @{ Key = "4"; Label = "Search Index"; Desc = "Reset Windows Search (Admin)"; Action = { Repair-SearchIndex } } - @{ Key = "5"; Label = "Store Cache"; Desc = "Reset Windows Store cache"; Action = { Repair-StoreCache } } - @{ Key = "A"; Label = "All Repairs"; Desc = "Run all of the above"; Action = { - Repair-DnsCache - Repair-FontCache - Repair-IconCache - Repair-SearchIndex - Repair-StoreCache - } } - @{ Key = "Q"; Label = "Quit"; Desc = "Exit"; Action = $null } - ) - - Write-Host "" - Write-Host "$esc[1;35m$($script:Icons.Admin) Mole Repair$esc[0m" - Write-Host "" - - if ($script:IsDryRun) { - Write-Host "$esc[33m$($script:Icons.DryRun) DRY RUN MODE$esc[0m - No changes will be made" - Write-Host "" - } - - Write-Host "$esc[90mSelect a repair to run:$esc[0m" - Write-Host "" - - foreach ($item in $menuItems) { - Write-Host " $esc[36m[$($item.Key)]$esc[0m $($item.Label) - $esc[90m$($item.Desc)$esc[0m" - } - - Write-Host "" - $choice = Read-Host "Choice" - - if ([string]::IsNullOrWhiteSpace($choice)) { - return - } - - $selected = $menuItems | Where-Object { $_.Key -eq $choice.ToUpper() } - - if ($selected -and $selected.Action) { - & $selected.Action - - # Show summary - Write-Host "" - if ($script:RepairsApplied -gt 0) { - Write-Host "$esc[32m$($script:Icons.Success)$esc[0m $($script:RepairsApplied) repair(s) applied" - } - else { - Write-Host "$esc[90mNo repairs applied$esc[0m" - } - } - elseif ($choice.ToUpper() -eq "Q") { - return - } - else { - Write-Host "$esc[31mInvalid choice$esc[0m" - } -} - -# ============================================================================ -# Main Entry Point -# ============================================================================ - -function Main { - $esc = [char]27 - - # Enable debug if requested - if ($DebugMode) { - $env:MOLE_DEBUG = "1" - $DebugPreference = "Continue" - } - - # Show help - if ($ShowHelp) { - Show-RepairHelp - return - } - - # Check if any specific repair was requested - $specificRepair = $DNS -or $Font -or $Icon -or $Search -or $Store -or $All - - if (-not $specificRepair) { - # No specific repair requested - show interactive menu - Show-RepairMenu - return - } - - # Run specific repairs - Write-Host "" - Write-Host "$esc[1;35m$($script:Icons.Admin) Mole Repair$esc[0m" - - if ($script:IsDryRun) { - Write-Host "" - Write-Host "$esc[33m$($script:Icons.DryRun) DRY RUN MODE$esc[0m - No changes will be made" - } - - if ($All -or $DNS) { - Repair-DnsCache - } - - if ($All -or $Font) { - Repair-FontCache - } - - if ($All -or $Icon) { - Repair-IconCache - } - - if ($All -or $Search) { - Repair-SearchIndex - } - - if ($All -or $Store) { - Repair-StoreCache - } - - # Show summary - Write-Host "" - if ($script:RepairsApplied -gt 0) { - if ($script:IsDryRun) { - Write-Host "$esc[33m$($script:Icons.DryRun)$esc[0m $($script:RepairsApplied) repair(s) would be applied" - } - else { - Write-Host "$esc[32m$($script:Icons.Success)$esc[0m $($script:RepairsApplied) repair(s) applied successfully" - } - } - else { - Write-Host "$esc[90mNo repairs applied$esc[0m" - } - Write-Host "" -} - -# Run main -Main diff --git a/mole.ps1 b/mole.ps1 index ad904d4..e82f4af 100644 --- a/mole.ps1 +++ b/mole.ps1 @@ -61,8 +61,7 @@ function Show-MainHelp { Write-Host " ${cyan}uninstall${nc} Smart application uninstaller" Write-Host " ${cyan}analyze${nc} Visual disk space analyzer" Write-Host " ${cyan}status${nc} Real-time system monitor" - Write-Host " ${cyan}optimize${nc} System optimization tasks" - Write-Host " ${cyan}repair${nc} Cache rebuilds and system fixes" + Write-Host " ${cyan}optimize${nc} System optimization and repairs" Write-Host " ${cyan}purge${nc} Clean project build artifacts" Write-Host "" Write-Host " ${green}OPTIONS:${nc}" @@ -72,16 +71,16 @@ function Show-MainHelp { Write-Host "" Write-Host " ${green}EXAMPLES:${nc}" Write-Host "" - Write-Host " ${gray}mole${nc} ${gray}# Interactive menu${nc}" - Write-Host " ${gray}mole clean${nc} ${gray}# Deep cleanup${nc}" - Write-Host " ${gray}mole clean -DryRun${nc} ${gray}# Preview cleanup${nc}" - Write-Host " ${gray}mole uninstall${nc} ${gray}# Uninstall apps${nc}" - Write-Host " ${gray}mole analyze${nc} ${gray}# Disk analyzer${nc}" - Write-Host " ${gray}mole status${nc} ${gray}# System monitor${nc}" - Write-Host " ${gray}mole optimize${nc} ${gray}# Optimize system${nc}" - Write-Host " ${gray}mole repair -DNS${nc} ${gray}# Flush DNS cache${nc}" - Write-Host " ${gray}mole repair -All${nc} ${gray}# Run all repairs${nc}" - Write-Host " ${gray}mole purge${nc} ${gray}# Clean dev artifacts${nc}" + Write-Host " ${gray}mole${nc} ${gray}# Interactive menu${nc}" + Write-Host " ${gray}mole clean${nc} ${gray}# Deep cleanup${nc}" + Write-Host " ${gray}mole clean -DryRun${nc} ${gray}# Preview cleanup${nc}" + Write-Host " ${gray}mole uninstall${nc} ${gray}# Uninstall apps${nc}" + Write-Host " ${gray}mole analyze${nc} ${gray}# Disk analyzer${nc}" + Write-Host " ${gray}mole status${nc} ${gray}# System monitor${nc}" + Write-Host " ${gray}mole optimize${nc} ${gray}# Optimize system${nc}" + Write-Host " ${gray}mole optimize -Repair${nc} ${gray}# Optimize + all repairs${nc}" + Write-Host " ${gray}mole optimize -Icon${nc} ${gray}# Optimize + rebuild icons${nc}" + Write-Host " ${gray}mole purge${nc} ${gray}# Clean dev artifacts${nc}" Write-Host "" Write-Host " ${green}ENVIRONMENT:${nc}" Write-Host "" @@ -124,16 +123,10 @@ function Show-MainMenu { } @{ Name = "Optimize" - Description = "System optimization" + Description = "Optimization & repairs" Command = "optimize" Icon = $script:Icons.Arrow } - @{ - Name = "Repair" - Description = "Cache rebuilds & fixes" - Command = "repair" - Icon = $script:Icons.Admin - } @{ Name = "Purge" Description = "Clean dev artifacts" From 381a5f064ca9821bd69ff21ad41361dd6f5b3b84 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 14 Jan 2026 03:53:52 +0000 Subject: [PATCH 10/10] chore: update contributors [skip ci] --- CONTRIBUTORS.svg | 95 +++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 42 deletions(-) diff --git a/CONTRIBUTORS.svg b/CONTRIBUTORS.svg index 7c22074..19e649f 100644 --- a/CONTRIBUTORS.svg +++ b/CONTRIBUTORS.svg @@ -1,4 +1,4 @@ - + @@ -135,46 +135,46 @@ - + - - - purofle + + + MohammedEsafi - + - - - huyixi + + + ndbroadbent - + - - - bunizao + + + Sizk - + - - - zeldrisho + + + thijsvanhal @@ -190,49 +190,60 @@ - + - - - thijsvanhal + + + zeldrisho - + - - - Sizk + + + bunizao - + - - - ndbroadbent + + + frozturk - + - - - MohammedEsafi + + + huyixi + + + + + + + + purofle + + + @@ -243,7 +254,7 @@ Schlauer-Hax - + @@ -254,7 +265,7 @@ anonymort - + @@ -265,7 +276,7 @@ khipu-luke - + @@ -276,7 +287,7 @@ LmanTW - + @@ -287,7 +298,7 @@ kwakubiney - + @@ -298,7 +309,7 @@ kowyo - + @@ -309,7 +320,7 @@ jalen0x - + @@ -320,7 +331,7 @@ Hensell - + @@ -331,7 +342,7 @@ ClathW - +