Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

Downloads:

1,044,906

Downloads of v 0.0.9.0:

17,757

Last Update:

04 May 2023

Package Maintainer(s):

Software Author(s):

  • bcurran3

Tags:

bcurran3 unofficial choco cleaner cleanup schtasks scheduled task

(unofficial) Choco Cleaner (Script + Task)

This is not the latest version of (unofficial) Choco Cleaner (Script + Task) available.

  • 1
  • 2
  • 3

0.0.9.0 | Updated: 04 May 2023

Downloads:

1,044,906

Downloads of v 0.0.9.0:

17,757

Maintainer(s):

Software Author(s):

  • bcurran3

(unofficial) Choco Cleaner (Script + Task) 0.0.9.0

This is not the latest version of (unofficial) Choco Cleaner (Script + Task) available.

  • 1
  • 2
  • 3

All Checks are Passing

3 Passing Tests


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install (unofficial) Choco Cleaner (Script + Task), run the following command from the command line or from PowerShell:

>

To upgrade (unofficial) Choco Cleaner (Script + Task), run the following command from the command line or from PowerShell:

>

To uninstall (unofficial) Choco Cleaner (Script + Task), run the following command from the command line or from PowerShell:

>

Deployment Method:

NOTE

This applies to both open source and commercial editions of Chocolatey.

1. Enter Your Internal Repository Url

(this should look similar to https://community.chocolatey.org/api/v2/)


2. Setup Your Environment

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

2. Get the package into your environment

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Copy Your Script

choco upgrade choco-cleaner -y --source="'INTERNAL REPO URL'" --version="'0.0.9.0'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade choco-cleaner -y --source="'INTERNAL REPO URL'" --version="'0.0.9.0'" 
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Install choco-cleaner
  win_chocolatey:
    name: choco-cleaner
    version: '0.0.9.0'
    source: INTERNAL REPO URL
    state: present

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'choco-cleaner' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '0.0.9.0'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


cChocoPackageInstaller choco-cleaner
{
    Name     = "choco-cleaner"
    Version  = "0.0.9.0"
    Source   = "INTERNAL REPO URL"
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'choco-cleaner':
  ensure   => '0.0.9.0',
  provider => 'chocolatey',
  source   => 'INTERNAL REPO URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Package Approved

This package was approved as a trusted package on 04 May 2023.

Description


choco://choco-cleaner

To use choco:// protocol URLs, install (unofficial) choco:// Protocol support


Screenshot of Choco-Cleaner

DO YOU WANT TO RECOVER SOME DISK SPACE USED BY UNNECESSARY RESIDUAL CHOCOLATEY FILES?

YOU JUST FOUND THE EASY WAY!

This package creates a Windows Scheduled Task to run Choco-Cleaner.ps1 every Sunday at 11:00 PM.

BEFORE and AFTER Choco-Cleaner: (198 packages installed and does not include temp folder deletions.)

schreenshot of files and diskspace  before Choco-Cleaner screenshot of files and diskspace after choco-cleaner

Sure, you're probably not going to get gigabytes of space back, but every few KB matters on some computers and to some people! Due to slack space small files such as 6 byte .ignore files actually take up 4 KB of HDD space each.

FEATURES:

Set it and forget it! Choco-Cleaner cleans up your Chocolatey installation every Sunday at 11 PM in the background so you don't have to be bothered with it.

Choco-Cleaner is completely configurable, just edit \ProgramData\chocolatey\bin\Choco-Cleaner.xml and set true/false for any grouping of file types you want to delete or not. License and log files default to false. This has been mandated to me by Chocolatey for passing moderation. Everything else listed below is deleted by default.

Choco-Cleaner deletes:

  • .log files that are not the most current one (NOT default)
  • .zip and various archive files left over from packages that forgot to delete them post install
  • .zip.txt and other archive-extensions.txt are lists of files that were extracted from an archive file for installation
  • .msi, .msu, and .msp are Microsoft intall packages left over from packages that forgot to delete them post install
  • .ignore files that are created to not shim executables during package install but not needed after shim operations are finished (This may change in a future version of Chocolatey.)
  • credits.txt are program credits (of contributors) files you can read on the web
  • readme.txt files you can read on the web
  • .md files are usually markdown readme files that you can read on the web
  • .old files are Chocolatey files that have been replaced by newer versions (exe's and dll's mostly)
  • chocolatey.config.backup is a backup of your chocolatey.config file
  • _processed.txt - I have no idea what made this file or why it exists
  • lib-bad holds packages that failed to install and lib-bkp contains aborted packages (during updates?)
  • archives and executables out of .nupkg files which are ZIP archives with NuGet package information - this is similar to what Package Reducer does
  • \users\username\AppData\Local\Temp\chocolatey is where new package files are downloaded to during pre-installation (if you haven't changed your cacheLocation in chocolatey.config)
  • files in cacheLocation if set in chocolatey.config
  • \users\username\AppData\Local\Nuget\Cache if Nuget client is installed and caching files there
  • \Windows\Temp\chocolatey
  • license.txt and verification.txt files are included when packages include binaries, you can read them on the package web page, programname.license.txt files are license files for Chocolatey default tools (NOT default)
  • orphaned shim files for programs that no longer exist

If you find Choco-Cleaner useful, and I suspect you will, please consider donating: https://www.paypal.me/bcurran3donations or become a patron at https://www.patreon.com/bcurran3


tools\.SkipAutoUninstaller
 
tools\choco-cleaner.config
<?xml version="1.0"?>
<Settings>
  <Preferences>
    <DeleteLicenseFiles>false</DeleteLicenseFiles>  
    <DeleteLogs>false</DeleteLogs>
    <DeleteFileLogs>false</DeleteFileLogs>	
    <DeleteArchives>true</DeleteArchives>
    <DeleteMSInstallers>true</DeleteMSInstallers>
    <DeleteIgnoreFiles>true</DeleteIgnoreFiles>
    <DeleteReadmes>true</DeleteReadmes>
    <DeleteOldChoco>true</DeleteOldChoco>
    <DeleteConfigBackupFile>true</DeleteConfigBackupFile>
    <DeleteLibBad>true</DeleteLibBad>
    <DeleteLibBkp>true</DeleteLibBkp>
    <Optimizenupkg>true</Optimizenupkg>
    <DeleteCache>true</DeleteCache>
	<DeleteNuGetCache>true</DeleteNuGetCache>
  </Preferences>
</Settings>

<!--
#######################################################################################################################
# You can comment out anything above that you do not want to delete such as log or license files with a # at the front of the line.
# File deletion statements (Remove-Item) are purposely grouped for easy disabling based on types of files.
# 
# LEGEND:
# * .log files that are not the most current one
# * .zip, .rar, .iso, and various archive files left over from packages that forgot to delete them post install
# * .zip.txt and other archive-extensions.txt are lists of files that were extracted from an archive file for installation
# * .msi, .msu, and .msp are Microsoft intall packages left over from packages that forgot to delete them post install
# * .ignore files are created to not shim executables during package install but not needed after shim operations are finished (This may change in a # future version of Chocolatey.)
# * credits.txt are program credits (of contributors) files you can read on the web
# * readme.txt files you can read on the web
# * .md files are usually markdown readme files that you can read on the web
# * .old files are Chocolatey files that have been replaced by newer versions (exe's and dll's mostly)
# * chocolatey.config.backup is a backup of your chocolatey.config file
# * _processed.txt - I have no idea what made this file
# * lib-bad holds packages that failed to install and lib-bkp contains aborted packages (during updates?) 
# * archives and executables out of .nuspkg files which are ZIP archives with NuGet package information - this is similar to what [Package Reducer](https://chocolatey.org/docs/features-package-reducer) does
# * \Users\username\AppData\Local\Temp\chocolatey is where new package files are downloaded to during pre-installation (if you haven't changed your cacheLocation in chocolatey.config)
# * license.txt and verification.txt files are included when packages include binaries, you can read them on the package web page, programname.license.txt files are license files for Chocolatey default tools
# * NuGet cach is where NuGet stores cached .nupkg files
#######################################################################################################################
-->
tools\choco-cleaner.ico
 
tools\choco-cleaner.ps1
$ErrorActionPreference = 'Continue'
#Requires -RunAsAdministrator
# Choco-Cleaner.ps1 Copyleft 2017-2023 by Bill Curran AKA BCURRAN3
# LICENSE: GNU GPL v3 - https://www.gnu.org/licenses/gpl.html
# Open a GitHub issue at https://github.com/bcurran3/ChocolateyPackages/issues if you have suggestions for improvement.

Write-Host "Choco-Cleaner.ps1 v0.0.9.0 (05/03/2023) - deletes unnecessary residual Chocolatey files to free up disk space" -Foreground White
Write-Host "Copyleft 2017-2023 Bill Curran ([email protected]) - free for personal and commercial use`n" -Foreground White

# Verify ChocolateyToolsLocation was created by Get-ToolsLocation during install and is in the environment
if (!($ENV:ChocolateyToolsLocation)) {$ENV:ChocolateyToolsLocation = "$ENV:SystemDrive\tools"}
if (!(Test-Path "$ENV:ChocolateyToolsLocation\BCURRAN3")) {Write-Warning "Configuration not found. Please re-install.";throw}

# Easily edit the config file
if(Test-Path $ENV:ChocolateyInstall\bin\notepad++.exe){
	$Editor="notepad++.exe"
}else {
	$Editor="notepad.exe"
}

if ($args -eq "-EditConfig"){
	Write-Host "  ** Editing contents of choco-cleaner.config." -Foreground Magenta
	&$Editor "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.config"
	return
}

if ($args -eq "-ViewLog"){
	Write-Host "  ** Showing contents of choco-cleaner.log." -Foreground Magenta
	&$Editor "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.log"
	return
}

# Minor logging
if (Test-Path "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.log"){
	$LogSize=(Get-ChildItem -Path "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.log").length
	if ($LogSize -gt 4096){
		Remove-Item "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.log"  -ErrorAction SilentlyContinue
		if ($error[0].categoryinfo.category -match "PermissionDenied") {$PermissionErrors=$True}
		Write-Output "$(Get-Date) Choco-Cleaner Deleted log file" >> "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.log"
	}
}
Write-Output "$(Get-Date) Choco-Cleaner STARTED" >> "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.log"

# All 7Zip supported formats plus EXE, MSU, MSP, APPX, APPXBUNDLE, IMG - What else is needed?
$BinaryExtensions=@(
	"*.exe","*.img","*.msu","*.msp","*.appx","*.appxbundle","*.7z","*.xz",
	"*.bzip2","*.gzip","*.tar","*.zip","*.wim","*.ar","*.arj","*.cab","*.chm",
	"*.cpio","*.cramfs","*.dmg","*.ext","*.fat","*.gpt","*.hfs","*.ihex",
	"*.iso","*.lzh","*.lzma","*.mbr","*.msi","*.nsis","*.ntfs","*.qcow2",
	"*.rar","*.rpm","*.squashfs","*.udf","*.uefi","*.vdi","*.vhd","*.vmdk",
	"*.xar","*.z","*.dll"
)

# All log file types
$file_log_types = @(
	"*.zip.txt","*.exe.txt","*.rar.txt","*.7z.txt","*.gz.txt","*.tar.txt",
	"*.sfx.txt","*.iso.txt"
)

# All temporary archive types
$archive_types = @(
	"*.zip","*.rar","*.7z","*.gz","*.tar","*.sfx","*.iso","*.img","*.appx",
	"*.appxbundle","*.bzip2","*.gzip","*.tar","*.lzh","*.z"
)

# All license text types
$license_types = @( "license.txt","*.license.txt","verification.txt" )

# All embedded installer types
$embed_types = @( "*.msi","*.msu","*.msp" )

# All readme types
$readme_types = @( "credits.txt","readme.txt","*.md" )

# Import preferences from choco-cleaner.config
[xml]$ConfigFile = Get-Content "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.config"
$DeleteLogs = $ConfigFile.Settings.Preferences.DeleteLogs
$DeleteArchives = $ConfigFile.Settings.Preferences.DeleteArchives
$DeleteFileLogs = $ConfigFile.Settings.Preferences.DeleteFileLogs
$DeleteMSInstallers = $ConfigFile.Settings.Preferences.DeleteMSInstallers
$DeleteIgnoreFiles = $ConfigFile.Settings.Preferences.DeleteIgnoreFiles
$DeleteReadmes = $ConfigFile.Settings.Preferences.DeleteReadmes
$DeleteOldChoco = $ConfigFile.Settings.Preferences.DeleteOldChoco
$DeleteConfigBackupFile = $ConfigFile.Settings.Preferences.DeleteConfigBackupFile
$DeleteLibBad = $ConfigFile.Settings.Preferences.DeleteLibBad
$DeleteLibBkp = $ConfigFile.Settings.Preferences.DeleteLibBkp
$Optimizenupkg = $ConfigFile.Settings.Preferences.Optimizenupkg
$DeleteCache = $ConfigFile.Settings.Preferences.DeleteCache
$DeleteLicenseFiles = $ConfigFile.Settings.Preferences.DeleteLicenseFiles
# new configuration items since implementation of XML config in v0.0.3
$DeleteNuGetCache = $ConfigFile.Settings.Preferences.DeleteNuGetCache

$PermissionErrors=$False

# add to log file
function add2log {
    Param ( [string]$comment )
	
    Write-Host "  **  $comment" -Foreground Red
    Write-Output "$(Get-Date) Choco-Cleaner $comment" >> "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.log"
}

# run shim and report if the target program exists or not
function Test-ShimTargetExists {
	Param ( [Object][Parameter(Mandatory=$true, ValueFromPipeline=$true)]$ShimFile )

	$TargetExists = & "$ShimFile" "--shimgen-help" |
					 Select-String -pattern "Target Exists: 'True'"
	if (-not $TargetExists) {
		Return $false
	} else {
		Return $true
	}
}

# Import chocolatey.config and get cacheLocation if set
[xml]$ChocoConfigFile = Get-Content "$ENV:ChocolateyInstall\config\chocolatey.config"
$cacheLocation = $ChocoConfigFile.chocolatey.config | % { $_.add } | ? { $_.key -eq 'cacheLocation' } | Select -Expand value

if ($ENV:ChocolateyInstall -match $ENV:SystemDrive -and $ENV:SystemDrive -eq "C:"){
	$FreeBefore = Get-PSDrive C | foreach-object {$_.Free}
}
Write-Host "Choco-Cleaner Summary:" -Foreground Magenta

if (Test-Path $ENV:ChocolateyInstall\bin\_processed.txt){
	Write-Host "  **  Deleting unnecessary Chocolatey _processed.txt (WTF?) file..." -Foreground Green
	Remove-Item -Path $ENV:ChocolateyInstall\bin\_processed.txt -ErrorAction SilentlyContinue
	if ($error[0].categoryinfo.category -match "PermissionDenied") {
		$PermissionErrors=$True
		add2log "_processed.txt problems deleting due to permissions."
		}
}

if ($DeleteIgnoreFiles -eq "True"){
	$GotIgnoreFiles=Get-ChildItem -Path $ENV:ChocolateyInstall -Recurse -Include *.ignore -ErrorAction SilentlyContinue
	if ($error[0].categoryinfo.category -match "PermissionDenied") {
        $PermissionErrors=$True
		$ErrorPath=$error[0].categoryinfo.targetname
	    add2log "PROBLEM reading $ErrorPath due to permissions."
		}
	$IgnoreFiles=$GotIgnoreFiles.count
	if ($IgnoreFiles -ge 1){
		Write-Host "  **  Deleting $IgnoreFiles unnecessary Chocolatey .ignore files..." -Foreground Green
		Remove-Item -Path $ENV:ChocolateyInstall -Recurse -Include *.ignore -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		$PermissionErrors=$True
	    	add2log "PROBLEM deleting unnecessary Chocolatey .ignore files due to permissions."
	    }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey .ignore files to delete." -Foreground Green
	}
}

if ($DeleteOldChoco -eq "True"){
	$GotOldChoco=Get-ChildItem -Path $ENV:ChocolateyInstall -Recurse -Include *.old -ErrorAction SilentlyContinue
	if ($error[0].categoryinfo.category -match "PermissionDenied") {
        $PermissionErrors=$True
		$ErrorPath=$error[0].categoryinfo.targetname
	    add2log "PROBLEM reading $ErrorPath due to permissions."
		}
	$OldChoco=$GotOldChoco.count
	if ($OldChoco -ge 1){
		Write-Host "  **  Deleting $OldChoco unnecessary Chocolatey .old files..." -Foreground Green
		Remove-Item -Path $ENV:ChocolateyInstall -Recurse -Include *.old -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		$PermissionErrors=$True
	    	add2log "PROBLEM deleting Chocolatey .old files due to permissions."
        }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey .old files to delete." -Foreground Green
	}
}

if ($DeleteCache -eq "True"){
	$UserDirs=Get-ChildItem -Path C:\Users -Directory -Force -ErrorAction SilentlyContinue | Select-Object FullName
	for ($Count = 0; $Count -lt $UserDirs.FullName.Count; $Count++){
		$dir = $userdirs.fullname[$Count]
		$dir = "$dir" + "\appdata\local\temp\chocolatey"
    	$GotCacheFiles=ChildItem -Path $dir -Recurse -ErrorAction SilentlyContinue
	    $CacheFiles=$GotCacheFiles.count
	    if ($CacheFiles -ge 1){
		    Write-Host "  **  Deleting $CacheFiles unnecessary Chocolatey cache files ($dir)..." -Foreground Green
		    Remove-Item $dir -Recurse -Force -ErrorAction SilentlyContinue
	        if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		    $PermissionErrors=$True
	    	    add2log "PROBLEM deleting unnecessary Chocolatey cache files ($dir) due to permissions."
		    }
	    } else {
		  Write-Host "  **  NO unnecessary Chocolatey cache files ($dir) to delete." -Foreground Green
	    }
    }

	$GotCacheFiles=ChildItem -Path $ENV:SystemRoot\temp\chocolatey -Recurse -ErrorAction SilentlyContinue
	if ($error[0].categoryinfo.category -match "PermissionDenied") {
        $PermissionErrors=$True
		$ErrorPath=$error[0].categoryinfo.targetname
	    add2log "PROBLEM reading $ErrorPath due to permissions."
		}
	$CacheFiles=$GotCacheFiles.count
	if ($CacheFiles -ge 1){
		Write-Host "  **  Deleting $CacheFiles unnecessary Chocolatey cache files ($ENV:SystemRoot\temp\chocolatey)..." -Foreground Green
		Remove-Item -Path $ENV:SystemRoot\temp\chocolatey -Recurse -Force -ErrorAction SilentlyContinue
        if ($error[0].categoryinfo.category -match "PermissionDenied") {
   		    $PermissionErrors=$True
    	    add2log "PROBLEM deleting unnecessary Chocolatey cache files ($ENV:SystemRoot\temp\chocolatey) due to permissions."
	    }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey cache files ($ENV:SystemRoot\temp\chocolatey) to delete." -Foreground Green
	}

	if ($cacheLocation){
		if (Test-Path $cacheLocation) {
			$GotCacheFiles=ChildItem -Path $cacheLocation -Recurse -ErrorAction SilentlyContinue
	        if ($error[0].categoryinfo.category -match "PermissionDenied") {
                $PermissionErrors=$True
		        $ErrorPath=$error[0].categoryinfo.targetname
	            add2log "PROBLEM reading $ErrorPath due to permissions."
		    }
			$CacheFiles=$GotCacheFiles.count
			if ($CacheFiles -ge 1){
				Write-Host "  **  Deleting $CacheFiles unnecessary Chocolatey cache files ($cacheLocation)..." -Foreground Green
				Remove-Item -Path $cacheLocation -Recurse -Force -ErrorAction SilentlyContinue
	            if ($error[0].categoryinfo.category -match "PermissionDenied") {
      		        $PermissionErrors=$True
	    	        add2log "PROBLEM deleting unnecessary Chocolatey cache files ($cacheLocation) due to permissions."
		            }
			} else {
				Write-Host "  **  NO unnecessary Chocolatey cache files ($cacheLocation) to delete." -Foreground Green
			}
		}
	}
}

if ($DeleteNuGetCache -eq "True"){
	$UserDirs=Get-ChildItem -Path C:\Users -Directory -Force -ErrorAction SilentlyContinue | Select-Object FullName
	for ($Count = 0; $Count -lt $UserDirs.FullName.Count; $Count++){
		$dir = $userdirs.fullname[$Count]
		$dir = "$dir" + "\appdata\Local\Nuget\Cache"
		$GotNuGetCache=ChildItem -Path $dir -Recurse -ErrorAction SilentlyContinue
		$NuGetCache=$GotNuGetCache.count
		if ($NuGetCache -ge 1){
			Write-Host "  **  Deleting $NuGetCache unnecessary Nuget cache files ($dir)..." -Foreground Green
		    Remove-Item $dir -Recurse -Force -ErrorAction SilentlyContinue
	        if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		    $PermissionErrors=$True
	    	    add2log "PROBLEM deleting unnecessary Nuget cache files ($dir) due to permissions."
		        }
		} else {
			Write-Host "  **  NO unnecessary Nuget cache files ($dir) to delete." -Foreground Green
		}
	}
}

if ($DeleteConfigBackupFile -eq "True"){
	if (Test-Path $ENV:ChocolateyInstall\config\chocolatey.config.backup){
		Write-Host "  **  Deleting unnecessary Chocolatey config backup file..." -Foreground Green
		Remove-Item -Path $ENV:ChocolateyInstall\config\chocolatey.config.backup -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    	   $PermissionErrors=$True
	       add2log "PROBLEM deleting unnecessary Chocolatey config backup file due to permissions."
		   }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey config backup file to delete." -Foreground Green
	}
}

if ($DeleteLibBad -eq "True"){
	if (Test-Path $ENV:ChocolateyInstall\lib-bad){
		$GotLibBadFiles=Get-ChildItem -Path $ENV:ChocolateyInstall\lib-bad | ?{ $_.PSIsContainer }
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
            $PermissionErrors=$True
		    $ErrorPath=$error[0].categoryinfo.targetname
	        add2log "PROBLEM reading $ErrorPath due to permissions."
		}
		$LibBadFiles=$GotLibBadFiles.count
		if ($LibBadFiles -ge 1){
			Write-Host "  **  Deleting $LibBadFiles unnecessary Chocolatey lib-bad package files..." -Foreground Green
		} else {
			Write-Host "  **  NO unnecessary Chocolatey lib-bad package files to delete." -Foreground Green
		}
		Remove-Item -Path $ENV:ChocolateyInstall\lib-bad -Recurse -Force -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    	   $PermissionErrors=$True
	       add2log "PROBLEM deleting unnecessary Chocolatey lib-bad files due to permissions."
		   }
	}
}

if ($DeleteLibBkp -eq "True"){
	if (Test-Path $ENV:ChocolateyInstall\lib-bkp){
		$GotLibBkpFiles=Get-ChildItem -Path $ENV:ChocolateyInstall\lib-bkp | ?{ $_.PSIsContainer }
        if ($error[0].categoryinfo.category -match "PermissionDenied") {
            $PermissionErrors=$True
            $ErrorPath=$error[0].categoryinfo.targetname
	        add2log "PROBLEM reading $ErrorPath due to permissions."
	    }
		$LibBkpFiles=$GotLibBkpFiles.count
		if ($LibBkpFiles -ge 1){
			Write-Host "  **  Deleting $LibBkpFiles unnecessary Chocolatey lib-bkp package files..." -Foreground Green
		} else {
			Write-Host "  **  NO unnecessary Chocolatey lib-bkp package files to delete." -Foreground Green
		}
		Remove-Item -Path $ENV:ChocolateyInstall\lib-bkp -Recurse -Force -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    	   $PermissionErrors=$True
	       add2log "PROBLEM deleting unnecessary Chocolatey lib-bkp files due to permissions."
		   }
	}
}

# FUTURE (placeholder)
#if ($DeleteLibSynced -eq "True"){
#	Write-Host "  **  Deleting unnecessary Chocolatey lib-synced package files..." -Foreground Green
#	Remove-Item -Path $ENV:ChocolateyInstall\lib-synced -Recurse -ErrorAction SilentlyContinue
#   if ($error[0].categoryinfo.category -match "PermissionDenied") {
#      $PermissionErrors=$True
#	   add2log "PROBLEM deleting LibSynced files due to permissions."
#	  }
#}

# FUTURE (placeholder)
#if ($DeleteDotChocolatey -eq "True"){
#	Write-Host "  **  Deleting unnecessary Chocolatey .chocolatey files..." -Foreground Green
#	Remove-Item -Path $ENV:ChocolateyInstall\.chocolatey -Recurse -ErrorAction SilentlyContinue
#   if ($error[0].categoryinfo.category -match "PermissionDenied") {
# 		$PermissionErrors=$True
#   	add2log "PROBLEM deleting .chocolatey files due to permissions."
#      }
#}

if ($DeleteFileLogs -eq "True"){
	$GotFileLogs=Get-ChildItem -Path $ENV:ChocolateyInstall -Recurse -Include $file_log_types -ErrorAction SilentlyContinue
    if ($error[0].categoryinfo.category -match "PermissionDenied") {
        $PermissionErrors=$True
        $ErrorPath=$error[0].categoryinfo.targetname
	    add2log "PROBLEM reading $ErrorPath due to permissions."
	}
	$FileLogs=$GotFileLogs.count
	if ($FileLogs -ge 1){
		Write-Host "  **  Deleting $FileLogs unnecessary Chocolatey extracted file logs..." -Foreground Green
		Remove-Item -Path $ENV:ChocolateyInstall -Recurse -Include $file_log_types -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		$PermissionErrors=$True
	    	add2log "PROBLEM deleting unnecessary Chocolatey extracted file logs due to permissions."
		    }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey extracted file logs to delete." -Foreground Green
	}
}

if ($DeleteLogs -eq "True"){
	$GotOldLogs=Get-ChildItem -Path $ENV:ChocolateyInstall\logs\*.log -Recurse -Exclude chocolatey.log,choco.summary.log -ErrorAction SilentlyContinue
    if ($error[0].categoryinfo.category -match "PermissionDenied") {
        $PermissionErrors=$True
        $ErrorPath=$error[0].categoryinfo.targetname
	    add2log "PROBLEM reading $ErrorPath due to permissions."
	}
	$FileLogs=$GotOldLogs.count
	if ($FileLogs -ge 1){
		Write-Host "  **  Deleting $FileLogs unnecessary Chocolatey log files..." -Foreground Green
		Remove-Item -Path $ENV:ChocolateyInstall\logs\*.log  -Exclude chocolatey.log,choco.summary.log -Recurse -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		$PermissionErrors=$True
	    	add2log "PROBLEM deleting unnecessary Chocolatey log files due to permissions."
		    }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey log files to delete." -Foreground Green
	}
}

if ($DeleteArchives -eq "True"){
	$GotArchvieFiles=Get-ChildItem -Path $ENV:ChocolateyInstall\lib -Recurse -Include $archive_types -ErrorAction SilentlyContinue
    if ($error[0].categoryinfo.category -match "PermissionDenied") {
        $PermissionErrors=$True
        $ErrorPath=$error[0].categoryinfo.targetname
	    add2log "PROBLEM reading $ErrorPath due to permissions."
	}
	$ArchiveFiles=$GotArchvieFiles.count
	if ($ArchiveFiles -ge 1){
		Write-Host "  **  Deleting $ArchiveFiles unnecessary Chocolatey package embedded archive files in toolsDir..." -Foreground Green
		Remove-Item -Path $ENV:ChocolateyInstall\lib -Recurse -Include $archive_types -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		$PermissionErrors=$True
	    	add2log "PROBLEM deleting unnecessary Chocolatey package embedded archive files due to permissions."
		    }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey package embedded archive files in toolsDir to delete." -Foreground Green
	}
}

if ($Optimizenupkg -eq "True"){
	Write-Host "  **  Deleting unnecessary Chocolatey package embedded archives and executables in .nupkg files..." -Foreground Green
	Get-Childitem $ENV:ChocolateyInstall\lib -Recurse -Include *.nupkg | ForEach-Object {& $ENV:ChocolateyInstall\tools\7z.exe d -r -tZIP $_.FullName $BinaryExtensions} | Out-Null
}

if ($DeleteLicenseFiles -eq "True"){
	$GotLicenseFiles=Get-ChildItem -Path $ENV:ChocolateyInstall\* -Recurse -Include $license_types -Exclude shimgen.license.txt -ErrorAction SilentlyContinue
    if ($error[0].categoryinfo.category -match "PermissionDenied") {
        $PermissionErrors=$True
        $ErrorPath=$error[0].categoryinfo.targetname
	    add2log "PROBLEM reading $ErrorPath due to permissions."
	}
	$LicenseFiles=$GotLicenseFiles.count
	if ($LicenseFiles -ge 1){
		Write-Host "  **  Deleting $LicenseFiles unnecessary Chocolatey package embedded license files..." -Foreground Green
		Remove-Item	-Path $ENV:ChocolateyInstall -Recurse -Include $license_types -Exclude shimgen.license.txt -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		$PermissionErrors=$True
	    	add2log "PROBLEM deleting unnecessary Chocolatey package embedded license files due to permissions."
		    }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey package embedded license files to delete." -Foreground Green
	}
}

if ($DeleteMSInstallers -eq "True"){
	$GotMSInstallers=Get-ChildItem -Path $ENV:ChocolateyInstall\lib -Recurse -Include $embed_types -ErrorAction SilentlyContinue
    if ($error[0].categoryinfo.category -match "PermissionDenied") {
        $PermissionErrors=$True
        $ErrorPath=$error[0].categoryinfo.targetname
	    add2log "PROBLEM reading $ErrorPath due to permissions."
	}
	$MSInstallers=$GotMSInstallers.count
	if ($MSInstallers -ge 1){
		Write-Host "  **  Deleting $MSInstallers unnecessary Chocolatey package embedded Microsoft installers..." -Foreground Green
		Remove-Item -Path $ENV:ChocolateyInstall\lib -Recurse -Include $embed_types -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		$PermissionErrors=$True
	    	add2log "PROBLEM deleting unnecessary Chocolatey package embedded Microsoft installer files due to permissions."
		    }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey package embedded Microsoft installers to delete." -Foreground Green
	}
}

if ($DeleteReadmes -eq "True"){
	$GotReadmes=Get-ChildItem -Path $ENV:ChocolateyInstall\* -Recurse -Include $readme_types -ErrorAction SilentlyContinue
	if ($error[0].categoryinfo.category -match "PermissionDenied") {
        $PermissionErrors=$True
		$ErrorPath=$error[0].categoryinfo.targetname
	    add2log "PROBLEM reading $ErrorPath due to permissions."
	    }
	$Readmes=$GotReadmes.count
	if ($Readmes -ge 1){
		Write-Host "  **  Deleting $Readmes unnecessary Chocolatey package embedded various read me files..." -Foreground Green
		Remove-Item -Path $ENV:ChocolateyInstall\* -Recurse -Include $readme_types -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		$PermissionErrors=$True
	    	add2log "PROBLEM deleting unnecessary Chocolatey package embedded various read me files due to permissions."
		    }
	} else {
		Write-Host "  **  NO unnecessary Chocolatey package embedded various read me files to delete." -Foreground Green
	}
}

$BadShimCount=0
Write-Host "  **  Checking shim files..." -NoNewline -Foreground Green
Get-ChildItem $ENV:ChocolateyInstall\bin\*.exe -ErrorAction SilentlyContinue | % {
	if (-not (Test-ShimTargetExists $PSItem) ){
		$BadShimCount = $BadShimCount +1
		Remove-Item "$PSItem" | Out-Null -ErrorAction SilentlyContinue
	    if ($error[0].categoryinfo.category -match "PermissionDenied") {
    		$PermissionErrors=$True
	    	add2log "PROBLEM deleting unnecessary Chocolatey orphaned shim files due to permissions."
		    }
	}
}
Write-Host "`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b                            `b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b" -NoNewLine
if ($BadShimCount){
	Write-Host "  **  Deleted $BadShimCount unnecessary Chocolatey orphaned shim files." -Foreground Green
} else {
	Write-Host "  **  NO unnecessary Chocolatey orphaned shim files to delete." -Foreground Green
}

if ($PermissionErrors) {Write-Host "  **  Some files not deleted due to permission problems.`n" -Foreground Yellow}

if ($ENV:ChocolateyInstall -Match $ENV:SystemDrive -and $ENV:SystemDrive -eq "C:"){
	$FreeAfter = Get-PSDrive C | ForEach-Object {$_.Free}
	$FreedSpace = $FreeAfter - $FreeBefore
	$FreedSpace = $FreedSpace / 1KB
	if ([int]$FreedSpace -lt 0) {$FreedSpace = 0}
	$FreedSpace = $FreedSpace.ToString('N0')
	Write-Host Choco-Cleaner finished deleting unnecessary Chocolatey files and reclaimed ~ $FreedSpace KB! -Foreground Magenta
	Write-Output "$(Get-Date) Choco-Cleaner FINISHED and reclaimed ~ $FreedSpace KB!" >> "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.log"
} else {
	Write-Host "Choco-Cleaner finished deleting unnecessary Chocolatey files!" -Foreground Magenta
	Write-Output "$(Get-Date) Choco-Cleaner FINISHED" >> "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-cleaner.log"
}
Write-Host "Found Choco-Cleaner.ps1 useful?" -ForegroundColor White
Write-Host "Buy me a beer at https://www.paypal.me/bcurran3donations" -ForegroundColor White
Write-Host "Become a patron at https://www.patreon.com/bcurran3" -ForegroundColor White
Start-Sleep -s 10

# TDL
# Accurately track and report reclaimed space per bullet point and total
# More detailed logging
# Clean C:\ProgramData\chocolatey\lib-synced
# Clean C:\ProgramData\chocolatey\.chocolatey
tools\chocolateyinstall.ps1
$ErrorActionPreference = 'Stop'
$packageName     = 'choco-cleaner'
$pp              = Get-PackageParameters
$toolsDir        = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$scriptDir       = "$(Get-ToolsLocation)\BCURRAN3"
$script          = 'choco-cleaner.ps1'
$ScriptConfig    = 'choco-cleaner.config'
$shortcutName    = 'Choco Cleaner.lnk'
$altshortcutName = 'Chocolatey Cleaner.lnk'

# Setup
# New storage location moving forward for all my Chocolatey scripts
$CTL=Get-ToolsLocation
if (!(Test-Path "$CTL\BCURRAN3")) { New-Item -Path "$CTL" -Name "BCURRAN3" -ItemType "Directory" | Out-Null }

# Migration
# Move files before v0.0.6 from old to new storage location
if (Test-Path "$ENV:ChocolateyInstall\bin\$script") { Remove-Item "$ENV:ChocolateyInstall\bin\$script" -Force }
if (Test-Path "$ENV:ChocolateyInstall\bin\choco-cleaner.xml") { Rename-Item "$ENV:ChocolateyInstall\bin\choco-cleaner.xml" $ScriptConfig -Force }
if (Test-Path "$ENV:ChocolateyInstall\bin\$ScriptConfig") { Move-Item "$ENV:ChocolateyInstall\bin\$ScriptConfig" "$scriptDir" -Force}

# Install Script
# Move new files and support files (if applicable)
Move-Item "$toolsDir\$script" "$scriptDir" -Force -ErrorAction SilentlyContinue
if (!(Test-Path "$scriptDir\$ScriptConfig")) { Move-Item "$toolsDir\$ScriptConfig" "$scriptDir" -Force }

# Create "shim"
Install-ChocolateyPowershellCommand -PackageName 'choco-cleaner' -PSFileFullPath "$scriptDir\$script"

# Cleanup
Remove-Item "$toolsDir\choco-cleaner.*" -Exclude choco-cleaner.ico -Force -ErrorAction SilentlyContinue | Out-Null

Function Update-Config{
[xml]$UpdatedConfig = Get-Content "$scriptDir\$ScriptConfig"

$DeleteNuGetCache = $UpdatedConfig.Settings.Preferences.DeleteNuGetCache
if ($DeleteNuGetCache -eq $null)
   {
    Write-Host Adding DeleteNuGetCache support to $ScriptConfig. -Foreground Magenta
	$NewStuff=$UpdatedConfig.CreateNode("element", "DeleteNuGetCache", $null)
    $NewStuff.InnerText=("true") 
	$UpdatedConfig.Settings.Preferences.AppendChild($NewStuff) | Out-Null
	$UpdatedFile = $True
   }
   
if ($UpdatedFile)
   {   
    $UpdatedConfig.Save("$scriptDir\$ScriptConfig")
	Write-Host "  ** Updated $ScriptConfig" -Foreground Magenta
   }
}

Update-Config

# Create Start Menu icon
If (Test-Path "$ENV:ProgramData\Microsoft\Windows\Start Menu\Programs\Chocolatey"){
      Install-ChocolateyShortcut -shortcutFilePath "$ENV:ProgramData\Microsoft\Windows\Start Menu\Programs\Chocolatey\$shortcutName" -targetPath "$env:ChocolateyInstall\bin\choco-cleaner.bat" -IconLocation "$toolsDir\choco-cleaner.ico" -RunAsAdmin
    } else {
      Install-ChocolateyShortcut -shortcutFilePath "$ENV:ProgramData\Microsoft\Windows\Start Menu\Programs\$altshortcutName" -targetPath "$env:ChocolateyInstall\bin\choco-cleaner.bat" -IconLocation "$toolsDir\choco-cleaner.ico" -RunAsAdmin
	}

# Remove previous scheduled task to fix v0.0.6 - v0.0.8 scheduled task execution bug
$ErrorActionPreference = 'SilentlyContinue'
$GotTask = (&schtasks /query /tn choco-cleaner) 2> $null
$ErrorActionPreference = 'Stop'
if ($GotTask -ne $null){&SchTasks /DELETE /TN "choco-cleaner" /F}

if ($pp["NOTASK"] -eq 'true' -or $pp["NOSCHEDULE"] -eq 'true'){
       Write-Host "  ** NOTASK or NOSCHEDULE specified, not installing scheduled task." -Foreground Magenta
	   Write-Host "You can manually run Choco-Cleaner from the Command Prompt, Powershell, or the Windows Start Menu icon." -Foreground Magenta
	   exit
   }

# Create scheduled task
SchTasks /Create /SC WEEKLY /D SUN /RU SYSTEM /RL HIGHEST /TN "choco-cleaner" /TR "%ChocolateyInstall%\bin\choco-cleaner.bat" /ST 23:00 /F
SchTasks /query /tn "choco-cleaner"
Write-Host "Now configured to run Choco-Cleaner at 11:00 PM every SUNDAY." -Foreground Green
Write-Host "You can manually run Choco-Cleaner from the Command Prompt, Powershell, or the Windows Start Menu icon." -Foreground Magenta
tools\chocolateyuninstall.ps1
$ErrorActionPreference = 'Stop'
$packageName     = 'choco-cleaner'
$scriptDir       = "$(Get-ToolsLocation)\BCURRAN3"
$shortcutName    = 'Choco Cleaner.lnk'
$altshortcutName = 'Chocolatey Cleaner.lnk'

$ErrorActionPreference = 'SilentlyContinue'
$GotTask         = (&schtasks /query /tn choco-cleaner) 2> $null
$ErrorActionPreference = 'Stop'
if ($GotTask) {SchTasks /Delete /TN “choco-cleaner” /F}

Remove-Item "$ENV:ProgramData\Microsoft\Windows\Start Menu\Programs\$shortcutName" -Force -ErrorAction SilentlyContinue
Remove-Item "$ENV:ProgramData\Microsoft\Windows\Start Menu\Programs\$altshortcutName" -Force -ErrorAction SilentlyContinue
Remove-Item "$ENV:ProgramData\Microsoft\Windows\Start Menu\Programs\Chocolatey\$shortcutName" -Force -ErrorAction SilentlyContinue
Remove-Item "$ENV:ChocolateyInstall\bin\choco-cleaner.bat" -Force -ErrorAction SilentlyContinue
Remove-Item "$scriptDir\choco-cleaner.*" -Force -ErrorAction SilentlyContinue | Out-Null
$CTL=Get-ToolsLocation
if (!(Get-ChildItem -Path "$CTL\BCURRAN3" | Measure-Object | %{$_.Count})) {
    $ENV:Path.Replace("$CTL\BCURRAN3","") | Out-Null
    Remove-Item "$CTL\BCURRAN3" | Out-Null
   }

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Add to Builder Version Downloads Last Updated Status
(unofficial) Choco Cleaner (Script + Task) 1.1.0 24243 Monday, June 12, 2023 Approved
(unofficial) Choco Cleaner (Script + Task) 1.0.0 41330 Wednesday, May 10, 2023 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.9.0 17757 Thursday, May 4, 2023 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.8.4 519588 Friday, May 28, 2021 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.8.3 11646 Tuesday, May 11, 2021 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.8.2 22477 Sunday, March 14, 2021 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.8.1 1822 Sunday, March 14, 2021 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.8 18535 Sunday, January 31, 2021 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.7.2 56147 Monday, April 6, 2020 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.7.1 10996 Thursday, January 16, 2020 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.7 5755 Saturday, December 28, 2019 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.6 433 Tuesday, December 17, 2019 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.5.2 12089 Thursday, January 10, 2019 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.5.1 1564 Tuesday, September 25, 2018 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.5 566 Friday, August 24, 2018 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.4 681 Sunday, June 10, 2018 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.3.1 301 Thursday, June 7, 2018 Approved
(unofficial) Choco Cleaner (Script + Task) 0.0.3 497 Wednesday, May 16, 2018 Approved

PACKAGE NOTES

INSTALL EXAMPLES:

  • choco install choco-cleaner - (default) installs Choco-Cleaner to run every Sunday at 11:00 PM
  • choco install choco-cleaner --params "'/NOTASK:TRUE'" - installs Choco-Cleaner without the scheduled task.

INSTRUCTIONS:

To manually run Choco-Cleaner:

  • Command Prompt or PowerShell: choco-cleaner
  • Windows Start Menu: click the icon. If you have choco-shortcuts-winconfig installed you'll find it with the rest of the Chocolatey Shortcuts.

If you have a previous release of Choco-Cleaner installed, upgrading to a new version will NOT modify your current scheduled task or preferences.

11:00 PM was chosen as not to conflict with default installs of choco-upgrade-all-at, choco-persistent-packages, and choco-optimize-at.

Organizations with software license compliance auditing should probably NOT delete the license and verification files for legal protection. The supplied configuration file defaults to false for these types of files. As ferventcoder/Rob has said many times, corporations are not advised to use the community repository and should be using Chocolatey for Business with their own internalized local packages.

SUGGESTION:

If you are using choco-upgrade-all-at or choco-upgrade-all-at-startup, run choco-upgrade-all -EditConfig and set choco-cleaner as your PostProcessScript.

CHANGELOG:

  • 0.0.9.0 - now recursively deletes chocolatey and Nuget cache files from all user profiles, added more error reporting, changed log size from 1K to 4K, added -ViewLog option
  • 0.0.8.5 - variable, spacing, and syntax cleanup by slycordinator, variables moved to top by Linux User
  • 0.0.8.4 - Fix exception when $FreedSpace is less than zero thanks to kborowinski - Thanks!
  • 0.0.8.3 - Fixed the reclaimed space calculation display thanks to salsifis - Thanks!
  • 0.0.8.2 - "Psycological Phix" - I hate seeing a negative number "reclaimed" after running Choco-Cleaner due to other programs writing to disk while CC is running; e.g. downloads. So until such time as I accurately track the space of deleted files... if the result is negative, it'll now display zero. Like I said, only a psychological fix.
  • 0.0.8.1 - Fixed v0.0.6 - v0.0.8 bug using unavailable environmental variable for scheduled task execution. Added small amount of logging.
  • 0.0.8 - Added checking and deleting of orphaned shim files thanks to TheCakeIsNaOH and Teknowledgist! New icon thanks to Teknowledgist. Added parameter to install without scheduled task. Added -EditConfig option to easily edit the config file.
  • 0.0.7.2 - Better error handling when $env:ChocolateyToolsLocation is not defined. (Usually due to running under a different account than installed from.)
  • 0.0.7.1 - Added checking to make sure that $env:ChocolateyToolsLocation exists. If you receive a "$env:ChocolateyToolsLocation not defined error message," you might simply need to close your CLI and reopen it if $env:ChocolateyToolsLocation was created during choco-cleaner's install.
  • 0.0.7 - Added some info about what and what isn't being deleted, added #Requires -RunAsAdministrator statement to script (PS v4+)
  • 0.0.6 - Fixed long standing bug where the config options set to false were ignored. Now works from Command Prompt as well as PowerShell. Additional 7Zip supported archives deleted.
  • 0.0.5.2 - minor update to delete .img (alternate .iso name), and .msi,.msu, and .msp files in toolsDir, as well as minor cosmetic changes
  • 0.0.5.1 - made PowerShell Core compatible
  • 0.0.5 - added deletion of cacheLocation if defined in chocolatey.config, cosmetic changes, removed 7Zip dependency and now using the version of 7Zip packaged with Chocolatey.
  • 0.0.4 - added deletion of Nuget Cache folder files
  • 0.0.3.1 - fixed typo causing nupkg files to NOT be optimized - thanks E.R.!
  • 0.0.3 - Rewritten version of 0.0.1 with XML configuration file and ferventcoder/Rob's approved default settings. Minor improvements.
  • 0.0.2 - Unreleased version with two scripts with different default settings; "Bill's way" and "Rob's way" and a package parameter to choose which one to use/install. Shelved.
  • 0.0.1 - Initial release. Did not pass Chocolatey moderation due to mandated changes of default parameters. Only "secretly" available.

ROADMAP:

  • Clean up C:\ProgramData\chocolatey.chocolatey
  • Clean up C:\ProgramData\chocolatey\lib-synced (licensed versions)
Discussion for the (unofficial) Choco Cleaner (Script + Task) Package

Ground Rules:

  • This discussion is only about (unofficial) Choco Cleaner (Script + Task) and the (unofficial) Choco Cleaner (Script + Task) package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or (unofficial) Choco Cleaner (Script + Task), or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus