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:

267,013

Downloads of v 0.0.7:

76,741

Last Update:

16 May 2023

Package Maintainer(s):

Software Author(s):

  • bcurran3

Tags:

bcurran3 unofficial choco upgrade all cup config schtasks scheduled task

(unofficial) Choco Upgrade All at (Task)

  • 1
  • 2
  • 3

0.0.7 | Updated: 16 May 2023

Downloads:

267,013

Downloads of v 0.0.7:

76,741

Maintainer(s):

Software Author(s):

  • bcurran3

(unofficial) Choco Upgrade All at (Task) 0.0.7

  • 1
  • 2
  • 3

This Package Contains an Exempted Check

Not All Tests Have Passed


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Exemption for this package version only:

This is an issue with how package-scanner currently works, and not with the package itself.

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install (unofficial) Choco Upgrade All at (Task), run the following command from the command line or from PowerShell:

>

To upgrade (unofficial) Choco Upgrade All at (Task), run the following command from the command line or from PowerShell:

>

To uninstall (unofficial) Choco Upgrade All at (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-upgrade-all-at -y --source="'INTERNAL REPO URL'" [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-upgrade-all-at -y --source="'INTERNAL REPO URL'" 
$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-upgrade-all-at
  win_chocolatey:
    name: choco-upgrade-all-at
    version: '0.0.7'
    source: INTERNAL REPO URL
    state: present

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


chocolatey_package 'choco-upgrade-all-at' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '0.0.7'
end

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


cChocoPackageInstaller choco-upgrade-all-at
{
    Name     = "choco-upgrade-all-at"
    Version  = "0.0.7"
    Source   = "INTERNAL REPO URL"
}

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


package { 'choco-upgrade-all-at':
  ensure   => '0.0.7',
  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.

WARNING

This package is exempt from moderation. While it is likely safe for you, there is more risk involved.

Description


choco://choco-upgrade-all-at

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


DO YOU WANT TO UPGRADE YOUR CHOCOLATEY PACKAGES EVERY DAY? OR MAYBE EVERY WEEK?

YOU JUST FOUND THE EASY WAY!

This package creates a Windows Scheduled Task to run "choco upgrade all -y" with enhanced options at a time and frequency you specify. And because sometimes package installations go wrong... it will also create a Windows Scheduled Task to run "taskkill /im choco.exe /f /t" to stop the Chocolatey (choco.exe) process and all child processes at a time you specify.

This package is a pseudo replacement for choco-upgrade-all-at-startup.

USAGE INSTRUCTIONS:

  • You can do nothing and it will run at the set it and forget it time. :)
  • You can manually run choco-upgrade-all from Command Prompt or PowerShell.
  • You can manually click the Upgrade All Packages icon in the Chocolatey Start Menu group if you have choco-shortcuts-winconfig installed.
  • You can manually run choco-install packagename from Command Prompt or PowerShell to install packages with your choco-upgrade-all-at settings.

INSTALL INSTRUCTIONS:

You can install choco-upgrade-all-at with multiple parameters to make it run "choco upgrade all -y" daily or weekly (Monthly is just not often enough!) at your preferred time. If you enter no parameters at all, choco-upgrade-all-at will default to run "choco upgrade all -y" at 2 AM every day and abort the process at 4 AM. When entering the TIME and ABORTTIME parameters, use "Military Time." When entering the DAILY or WEEKLY parameter you can actually use anything, "yes" just makes sense though. When using the WEEKLY parameter, DAYS are entered as MON, TUE, WED, THU, FRI, SAT, or SUN. Not entering the correct format will fail the install. Please see the examples below.

INSTALL EXAMPLES:

  • choco install choco-upgrade-all-at --params "'/TIME:23:00'" - runs "choco upgrade all -y" daily (default) at 11 PM and aborts at 1 AM, ABORTTIME defaults to +2 hours.
  • choco install choco-upgrade-all-at --params "'/DAILY:yes /TIME:04:00 /ABORTTIME:08:00'" - runs "choco upgrade all -y" daily at 4 AM and aborts it at 8 AM.
  • choco install choco-upgrade-all-at --params "'/WEEKLY:yes /DAY:SUN /TIME:01:00'" - runs "choco upgrade all -y" every Sunday at 1 AM and aborts at 3 AM.
  • choco install choco-upgrade-all-at --params "'/NOTASK:true'" - installs choco-upgrade-all.ps1/bat without the scheduled task.

CONFIGURATION INSTRUCTIONS:

Run choco-upgrade-all -EditConfig to enable enhanced options such as:

  • automatically delete newly installed Desktop and Start Menu icons
  • run pre and/or post processing scripts
  • setting a default user profile

SEE THE RELEASE NOTES FOR MORE INFORMATION

PACKAGE NOTES

If you find choco-upgrade-all-at 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\choco-install.ps1
$ErrorActionPreference = 'Stop'
#Requires -RunAsAdministrator
# choco-install.ps1 Copyleft 2021-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-Install.ps1 v0.0.7 (2023/05/10) - Install Chocolatey packages with enhanced options" -Foreground White
Write-Host "Copyleft 2021-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\choco-upgrade-all.config")) {Write-Warning "Configuration not found. Please re-install.";throw}

# Import preferences from choco-upgrade-all.config
[xml]$ConfigFile = Get-Content "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.config"
$ConfigArguments         = $ConfigFile.Settings.Preferences.ConfigArguments
$DebugLogging            = $ConfigFile.Settings.Preferences.DebugLogging
$DeleteNewDesktopIcons   = $ConfigFile.Settings.Preferences.DeleteNewDesktopIcons
$DeleteNewStartMenuIcons = $ConfigFile.Settings.Preferences.DeleteNewStartMenuIcons
$PreProcessScript        = $ConfigFile.Settings.Preferences.PreProcessScript
$PostProcessScript       = $ConfigFile.Settings.Preferences.PostProcessScript

$IconsDeleted=0

# Set Notepad++ as preferred editor/viewer
if (Test-Path $env:ChocolateyInstall\bin\notepad++.exe){
     $Editor="notepad++.exe"
    } else {
      $Editor="notepad.exe"
    }

# Easily edit the config file
if ($args -eq "-EditConfig") {
    Write-Host "  ** Editing contents of choco-upgrade-all.config." -Foreground Magenta
	&$Editor "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.config"
	return
}

# Run pre-processor if configured
if ($PreProcessScript){&$PreProcessScript}

# get existing Desktop and Start Menu icons
$UserDesktopIconsPre     = Get-ChildItem -Path "$env:USERPROFILE\Desktop\*.lnk"
if ($UserDesktopIconsPre -eq $null) {$UserDesktopIconsPre=0}
$PublicDesktopIconsPre   = Get-ChildItem -Path "$env:PUBLIC\Desktop\*.lnk"
if ($PublicDesktopIconsPre -eq $null) {$PublicDesktopIconsPre=0}
$UserStartMenuIconsPre   = Get-ChildItem -Path "$env:AppData\Microsoft\Windows\Start Menu\Programs\*.lnk" -Recurse
if ($UserStartMenuIconsPre -eq $null) {$UserStartMenuIconsPre=0}
$PublicStartMenuIconsPre = Get-ChildItem -Path "$env:ProgramData\Microsoft\Windows\Start Menu\*.lnk" -Recurse
if ($PublicStartMenuIconsPre -eq $null) {$PublicStartMenuIconsPre=0}

# Do the Chocolatey Humpty Hump
Start-Process -NoNewWindow -FilePath "$env:ChocolateyInstall\bin\choco.exe" -ArgumentList "install -y $ConfigArguments $args" -Wait

# get existing and new Desktop and Start Menu icons
$UserDesktopIconsPost     = Get-ChildItem -Path "$env:USERPROFILE\Desktop\*.lnk"
if ($UserDesktopIconsPost -eq $null) {$UserDesktopIconsPost=0}
$PublicDesktopIconsPost   = Get-ChildItem -Path "$env:PUBLIC\Desktop\*.lnk"
if ($PublicDesktopIconsPost -eq $null) {$PublicDesktopIconsPost=0}
$UserStartMenuIconsPost   = Get-ChildItem -Path "$env:AppData\Microsoft\Windows\Start Menu\Programs\*.lnk" -Recurse
if ($UserStartMenuIconsPost -eq $null) {$UserStartMenuIconsPost=0}
$PublicStartMenuIconsPost = Get-ChildItem -Path "$env:ProgramData\Microsoft\Windows\Start Menu\*.lnk" -Recurse
if ($PublicStartMenuIconsPost -eq $null) {$PublicStartMenuIconsPost=0}

# Delete new Desktop icons if configured to do so
if ($DeleteNewDesktopIcons -eq 'True'){
	if ($UserDesktopIconsPre.count -ne '0' -and $UserDesktopIconsPost.count -ne '0'){
       $IconsNew = Compare-Object -ReferenceObject ($UserDesktopIconsPre) -DifferenceObject ($UserDesktopIconsPost) -PassThru
       if ($IconsNew -ne $null) {
		    Remove-Item $IconsNew.fullname
			$IconsDeleted=$IconsDeleted + $IconsNew.count
	    }
	}
	if ($PublicDesktopIconsPre.count -ne '0' -and $PublicDesktopIconsPost.count -ne '0'){
       $IconsNew = Compare-Object -ReferenceObject ($PublicDesktopIconsPre) -DifferenceObject ($PublicDesktopIconsPost) -PassThru
       if ($IconsNew -ne $null) {
		   Remove-Item $IconsNew.fullname
		   $IconsDeleted=$IconsDeleted + $IconsNew.count
		}
    }
}
# Delete new Start Menu icons if configured to do so
if ($DeleteNewStartMenuIcons -eq 'True'){
	if ($UserStartMenuIconsPre.count -ne '0' -and $UserStartMenuIconsPost.count -ne '0'){
       $IconsNew = Compare-Object -ReferenceObject ($UserStartMenuIconsPre) -DifferenceObject ($UserStartMenuIconsPost) -PassThru
       if ($IconsNew -ne $null) {
		   Remove-Item $IconsNew.fullname
		   $IconsDeleted=$IconsDeleted + $IconsNew.count
		}
	   }
	if ($PublicStartMenuIconsPre.count -ne '0' -and $PublicStartMenuIconsPost.count -ne '0'){
       $IconsNew = Compare-Object -ReferenceObject ($PublicStartMenuIconsPre) -DifferenceObject ($PublicStartMenuIconsPost) -PassThru
       if ($IconsNew -ne $null) {
		   Remove-Item $IconsNew.fullname
		   $IconsDeleted=$IconsDeleted + $IconsNew.count
		}
    }
}

# Run post-processor if configured
if ($PostProcessScript){&$PostProcessScript}

Write-Host "`n  ** Choco-Install DELETED $IconsDeleted unwanted icon(s).`n" -ForegroundColor Magenta
Write-Host "Found Choco-Install.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
tools\choco-upgrade-all.config
<?xml version="1.0"?>
<Settings>
  <Preferences>
    <ConfigArguments></ConfigArguments>
    <DebugLogging>false</DebugLogging>
    <DefaultUserProfile></DefaultUserProfile>
    <DeleteNewDesktopIcons>false</DeleteNewDesktopIcons>  
    <DeleteNewStartMenuIcons>false</DeleteNewStartMenuIcons>
    <StopCUAAfter></StopCUAAfter>
    <PreProcessScript></PreProcessScript>
    <PostProcessScript></PostProcessScript>
  </Preferences>
</Settings>

<!--
#######################################################################################################################
# NOTE: All settings are disabled by default
# LEGEND:
# * ConfigArguments    - Additional options and switches to pass to choco.exe; e.g. Run choco upgrade /? to view options.
# * DebugLogging       - (True/False) Extra logging - EXPERIMENTAL
# * DefaultUserProfile - Default user profile to use when running as scheduled task; e.g. William, Robert, Benjamin (Look at C:\Users)
# * DeleteNewDesktopIcons   - (True/False) Delete newly created Desktop icons, user and public, after choco upgrade all
# * DeleteNewStartMenuIcons - (True/False) Delete newly created Start Menu icons, user and public, after choco upgrade all
# * StopCUAAfter       - Not implemented yet
# * PreProcessScript   - Script to run before choco upgrade all; e.g. c:\scripts\beforechoco.bat
# * PostProcessScript  - Script to run after choco upgrade all; e.g. c:\scripts\afterchoco.bat
#######################################################################################################################
-->
tools\choco-upgrade-all.ps1
$ErrorActionPreference = 'Stop'
#Requires -RunAsAdministrator
# choco-upgrade-all.ps1 Copyleft 2021-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-Upgrade-All.ps1 v0.0.7 (2023/05/15) - Upgrade your Chocolatey packages with enhanced options" -Foreground White
Write-Host "Copyleft 2021-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\choco-upgrade-all.config")) {Write-Warning "Configuration not found. Please re-install.";throw}

# Import preferences from choco-upgrade-all.config
[xml]$ConfigFile = Get-Content "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.config"
$ConfigArguments         = $ConfigFile.Settings.Preferences.ConfigArguments
$DebugLogging            = $ConfigFile.Settings.Preferences.DebugLogging
$DefaultUserProfile      = $ConfigFile.Settings.Preferences.DefaultUserProfile
$DeleteNewDesktopIcons   = $ConfigFile.Settings.Preferences.DeleteNewDesktopIcons
$DeleteNewStartMenuIcons = $ConfigFile.Settings.Preferences.DeleteNewStartMenuIcons
#$StopCUAAfter            = $ConfigFile.Settings.Preferences.StopCUAAfter            # Not implemented yet
$PreProcessScript        = $ConfigFile.Settings.Preferences.PreProcessScript
$PostProcessScript       = $ConfigFile.Settings.Preferences.PostProcessScript

$IconsDeleted=0

# Set Notepad++ as preferred editor/viewer
if (Test-Path $env:ChocolateyInstall\bin\notepad++.exe){
     $Editor="notepad++.exe"
    } else {
      $Editor="notepad.exe"
    }

# Easily edit the config file
if ($args -eq "-EditConfig") {
    Write-Host "  ** Editing contents of choco-upgrade-all.config." -Foreground Magenta
	&$Editor "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.config"
	return
}

# Easily view the log file
if ($args -eq "-ViewLog") {
    Write-Host "  ** Viewing contents of choco-upgrade-all.log." -Foreground Magenta
	&$Editor "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.log"
	return
}

# Logging - always logging
if (Test-Path "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.log"){
   $LogSize=(Get-ChildItem -Path "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.log").length
   if ($LogSize -gt 40960) {
	   Remove-Item "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.log"
	   Write-Output "$(Get-Date) Choco-Upgrade-All Deleted log file" >> "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.log"
	  }
  }
Write-Output "----------------------------------------------------------------------" >> "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.log"
Write-Output "$(Get-Date) Choco-Upgrade-All STARTED" >> "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.log"


# add to log file
function Add2Log {
    Param ( [string]$comment )

    Write-Output "$(Get-Date) [INFO ] $comment" >> "$ENV:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.log"
}

if ($DebugLogging){
	Add2Log "CONFIG: DebugLogging is set to $DebugLogging. (ignored)"
} else {
		Add2Log "CONFIG: DebugLogging is not set. (ignored)"
}

# Run pre-processor if configured
if ($PreProcessScript){
	&$PreProcessScript
	Add2Log "EXECUTED: $PreProcessScript"
	}

# When running as SYSTEM (scheduled task) use the $DefaultUserProfile as the default user profile if defined
if ($DefaultUserProfile) {
	$env:USERPROFILE="$env:SystemDrive\Users\$DefaultUserProfile"
	$env:APPDATA="$env:SystemDrive\Users\$DefaultUserProfile\AppData\Roaming"
	Add2Log "CONFIG: DefaultUserProfile is set to $DefaultUserProfile"
} else {
		Add2Log "CONFIG: DefaultUserProfile is not set."
}


if ($ConfigArguments) {
    Add2Log "CONFIG: ConfigArguments are set to $ConfigArguments"
} else {
	Add2Log "CONFIG: ConfigArguments are not set."
}

# get existing Desktop and Start Menu icons
if (Test-Path "$env:USERPROFILE\Desktop") {$UserDesktopIconsPre = Get-ChildItem -Path "$env:USERPROFILE\Desktop\*.lnk"}
if ($UserDesktopIconsPre -eq $null) {$UserDesktopIconsPre=0}
if (Test-Path "$env:PUBLIC\Desktop") {$PublicDesktopIconsPre = Get-ChildItem -Path "$env:PUBLIC\Desktop\*.lnk"}
if ($PublicDesktopIconsPre -eq $null) {$PublicDesktopIconsPre=0}
if (Test-Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs") {$UserStartMenuIconsPre = Get-ChildItem -Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\*.lnk" -Recurse}
if ($UserStartMenuIconsPre -eq $null) {$UserStartMenuIconsPre=0}
if (Test-Path "$env:ProgramData\Microsoft\Windows\Start Menu") {$PublicStartMenuIconsPre = Get-ChildItem -Path "$env:ProgramData\Microsoft\Windows\Start Menu\*.lnk" -Recurse}
if ($PublicStartMenuIconsPre -eq $null) {$PublicStartMenuIconsPre=0}

# Do the Chocolatey Humpty Hump
Start-Process -NoNewWindow -FilePath "$env:ChocolateyInstall\bin\choco.exe" -ArgumentList "upgrade all -y $ConfigArguments $args" -Wait

# Get existing and new Desktop and Start Menu icons
if (Test-Path "$env:USERPROFILE\Desktop") {$UserDesktopIconsPost = Get-ChildItem -Path "$env:USERPROFILE\Desktop\*.lnk"}
if ($UserDesktopIconsPost -eq $null) {$UserDesktopIconsPost=0}
if (Test-Path "$env:PUBLIC\Desktop")  {$PublicDesktopIconsPost = Get-ChildItem -Path "$env:PUBLIC\Desktop\*.lnk"}
if ($PublicDesktopIconsPost -eq $null) {$PublicDesktopIconsPost=0}
if (Test-Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs") {$UserStartMenuIconsPost = Get-ChildItem -Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\*.lnk" -Recurse}
if ($UserStartMenuIconsPost -eq $null) {$UserStartMenuIconsPost=0}
if (Test-Path "$env:ProgramData\Microsoft\Windows\Start Menu") {$PublicStartMenuIconsPost = Get-ChildItem -Path "$env:ProgramData\Microsoft\Windows\Start Menu\*.lnk" -Recurse}
if ($PublicStartMenuIconsPost -eq $null) {$PublicStartMenuIconsPost=0}

# Delete new Desktop icons if configured to do so
if ($DeleteNewDesktopIcons -eq 'True'){
	Add2Log "CONFIG: DeleteNewDesktopIcons is set to TRUE"
	if ($UserDesktopIconsPre.count -ne '0' -and $UserDesktopIconsPost.count -ne '0'){
       $IconsNew = Compare-Object -ReferenceObject ($UserDesktopIconsPre) -DifferenceObject ($UserDesktopIconsPost) -PassThru
       if ($IconsNew -ne $null) {
		   Remove-Item $IconsNew.fullname
		   $IconsDeleted=$IconsDeleted + $IconsNew.count
	       $IconsNew | % {Add2Log "DELETED: $_"}
	    }
	}
	if ($PublicDesktopIconsPre.count -ne '0' -and $PublicDesktopIconsPost.count -ne '0'){
       $IconsNew = Compare-Object -ReferenceObject ($PublicDesktopIconsPre) -DifferenceObject ($PublicDesktopIconsPost) -PassThru
       if ($IconsNew -ne $null) {
		   Remove-Item $IconsNew.fullname
		   $IconsDeleted=$IconsDeleted + $IconsNew.count
	       $IconsNew | % {Add2Log "DELETED: $_"}
	    }
    }
} else {
	Add2Log "CONFIG: DeleteNewDesktopIcons is set to FALSE"
}

# Delete new Start Menu icons if configured to do so
if ($DeleteNewStartMenuIcons -eq 'True'){
	Add2Log "CONFIG: DeleteNewStartMenuIcons is set to TRUE"
	if ($UserStartMenuIconsPre.count -ne '0' -and $UserStartMenuIconsPost.count -ne '0'){
       $IconsNew = Compare-Object -ReferenceObject ($UserStartMenuIconsPre) -DifferenceObject ($UserStartMenuIconsPost) -PassThru
       if ($IconsNew -ne $null) {
		   Remove-Item $IconsNew.fullname
		   $IconsDeleted=$IconsDeleted + $IconsNew.count
	       $IconsNew | % {Add2Log "DELETED: $_"}
	    }
    }
	if ($PublicStartMenuIconsPre.count -ne '0' -and $PublicStartMenuIconsPost.count -ne '0'){
       $IconsNew = Compare-Object -ReferenceObject ($PublicStartMenuIconsPre) -DifferenceObject ($PublicStartMenuIconsPost) -PassThru
       if ($IconsNew -ne $null) {
		   Remove-Item $IconsNew.fullname
		   $IconsDeleted=$IconsDeleted + $IconsNew.count
	       $IconsNew | % {Add2Log "DELETED: $_"}
	    }
    }
} else {
	Add2Log "CONFIG: DeleteNewStartMenuIcons is set to FALSE"
}

# Run post-processor if configured
if ($PostProcessScript){
	&$PostProcessScript
	Add2Log "EXECUTED: $PostProcessScript"
	}

if (($DeleteNewDesktopIcons -eq 'True') -or ($DeleteNewStartMenuIcons -eq 'True')){
    Add2Log "DELETED $IconsDeleted unwanted shortcut(s)."
    Write-Host "`n  ** Choco-Upgrade-All DELETED $IconsDeleted unwanted shortcut(s).`n" -ForegroundColor Magenta
}

Write-Host "Found Choco-Upgrade-All.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
Write-Output "$(Get-Date) Choco-Upgrade-All FINISHED" >> "$env:ChocolateyToolsLocation\BCURRAN3\choco-upgrade-all.log"
tools\chocolateyinstall.ps1
$ErrorActionPreference = 'Stop'
$packageName  = 'choco-upgrade-all-at'
$toolsDir     = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$pp           = Get-PackageParameters
$scriptDir    = "$(Get-ToolsLocation)\BCURRAN3"
$script       = 'choco-upgrade-all.ps1'
$ScriptConfig = 'choco-upgrade-all.config'

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

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

# Create "shim"
Install-ChocolateyPowershellCommand -PackageName 'choco-upgrade-all' -PSFileFullPath "$scriptDir\$script"
Install-ChocolateyPowershellCommand -PackageName 'choco-install' -PSFileFullPath "$scriptDir\choco-install.ps1"

# Cleanup
Remove-Item "$toolsDir\choco-upgrade-all.*" -Force -ErrorAction SilentlyContinue | Out-Null

# delete old task name < v0.0.4 if it exists
$ErrorActionPreference = 'Continue'
$GotTask = (&schtasks /QUERY /TN "choco upgrade all at") 2> $null
$ErrorActionPreference = 'Stop'
if ($GotTask -ne $null){
     &SchTasks /DELETE /TN "choco upgrade all at" /F 
   }

$ErrorActionPreference = 'Continue'
$GotTask      = (&schtasks /QUERY /TN "choco-upgrade-all-at") 2> $null
$ErrorActionPreference = 'Stop'

# Change task to run new batch file and keep other existing settings (v0.0.0.5 to v0.0.0.6 upgrade)
if ($GotTask -ne $null){
     &SchTasks /CHANGE /TN "choco-upgrade-all-at" /TR "%ChocolateyInstall%\bin\choco-upgrade-all.bat"
   }

# check if choco-ugrade-all-at task already exists and exit if so
if ($GotTask -ne $null){
     Write-Host "  ** Existing choco-upgrade-all-at scheduled task found. Keeping existing scheduled task.`n     If you want to change the task runtime or abort time, uninstall and reinstall the package." -Foreground Magenta 
     exit
   }

# exit if a scheduled task is not wanted
if ($pp["NOTASK"] -eq 'true' -or $pp["NOSCHEDULE"] -eq 'true'){
       Write-Host "  ** NOTASK or NOSCHEDULE specified, not installing scheduled task." -Foreground Magenta
	   exit
   }

# begin setup of scheduled task if one doesn't exist
Write-Host "" 
Write-Host "CHOCO-UPGRADE-ALL-AT Summary:" -Foreground Magenta

if ($pp["USER"] -eq $null -or $pp["USER"] -eq ''){
       Write-Host "  ** USER NOT specified, defaulting to SYSTEM." -Foreground Magenta
	   $RunAsUser = 'SYSTEM'
     } else {
	   if ($pp["USER"] -eq 'CURRENTUSER'){
	       $RunAsUser = $env:USERNAME
	       } else {
	         $RunAsUser = $pp["USER"]
	         Write-Host " ** USER specified as $RunAsUser." -Foreground Magenta
            } 
	}

if ($pp["TIME"] -eq $null -or $pp["TIME"] -eq ''){
	   $RunTime = "02:00"
       Write-Host "  ** TIME NOT specified, defaulting to $RunTime." -Foreground Magenta
     } else {
	   $RunTime = $pp["TIME"]
	   Write-Host "  ** TIME specified as $RunTime." -Foreground Magenta
      } 

if ($pp["ABORTTIME"] -eq $null -or $pp["ABORTTIME"] -eq ''){
      $AbortTime = (Get-Date $RunTime).AddHours(2).ToString("HH:mm")
      Write-Host "  ** ABORTTIME NOT specified, defaulting to $AbortTime." -Foreground Magenta
    } else {
	  $AbortTime = $pp["ABORTTIME"]
	  Write-Host "  ** ABORTTIME specified as $AbortTime." -Foreground Magenta
    }
	  
if (($pp["DAILY"] -eq $null -or $pp["DAILY"] -eq '') -and ($pp["WEEKLY"] -eq $null -or $pp["WEEKLY"] -eq '')){
      Write-Host "  ** DAILY or WEEKLY NOT specified, defaulting to DAILY." -Foreground Magenta
      SchTasks /CREATE /SC DAILY /RU $RunAsUser /RL HIGHEST /TN choco-upgrade-all-at /TR "%ChocolateyInstall%\bin\choco-upgrade-all.bat" /ST $RunTime /F
	  SchTasks /QUERY /TN "choco-upgrade-all-at"
	  SchTasks /CREATE /SC DAILY /RU $RunAsUser /RL HIGHEST /TN choco-upgrade-all-at-abort /TR "taskkill /im choco.exe /f /t" /ST $AbortTime /F
      SchTasks /QUERY /TN "choco-upgrade-all-at-abort"
	  Start-Sleep -s 10
 	  exit
    }
		  
if ($pp["DAILY"] -eq $null -or $pp["DAILY"] -eq ''){
       Write-Host "  ** DAILY NOT specified." -Foreground Magenta
     } else {
	   Write-Host "  ** DAILY specified." -Foreground Magenta
	   SchTasks /CREATE /SC DAILY /RU $RunAsUser /RL HIGHEST /TN choco-upgrade-all-at /TR "%ChocolateyInstall%\bin\choco-upgrade-all.bat" /ST $RunTime /F
	   SchTasks /QUERY /TN "choco-upgrade-all-at"
	   SchTasks /CREATE /SC DAILY /RU $RunAsUser /RL HIGHEST /TN choco-upgrade-all-at-abort /TR "taskkill /im choco.exe /f /t" /ST $AbortTime /F
       SchTasks /QUERY /TN "choco-upgrade-all-at-abort"
	   Start-Sleep -s 10
	   exit
	   }  
		  
if ($pp["WEEKLY"] -eq $null -or $pp["WEEKLY"] -eq ''){
       Write-Host "  ** WEEKLY NOT specified." -Foreground Magenta
     } else {
	   Write-Host "  ** WEEKLY specified." -Foreground Magenta
       if ($pp["DAY"] -eq $null -or $pp["DAY"] -eq ''){
            Write-Host " * DAY NOT specified, defaulting to SUNDAY." -Foreground Magenta
            SchTasks /CREATE /SC WEEKLY /D SUN /RU $RunAsUser /RL HIGHEST /TN choco-upgrade-all-at /TR "%ChocolateyInstall%\bin\choco-upgrade-all.bat" /ST $RunTime /F
		    SchTasks /QUERY /TN "choco-upgrade-all-at"
			SchTasks /CREATE /SC WEEKLY /D SUN /RU $RunAsUser /RL HIGHEST /TN choco-upgrade-all-at-abort /TR "taskkill /im choco.exe /f /t" /ST $AbortTime /F
            SchTasks /QUERY /TN "choco-upgrade-all-at-abort"
          } else {
		    $RunDay = $pp["DAY"]
            Write-Host "  ** DAY specified as $RunDay." -Foreground Magenta
		    SchTasks /CREATE /SC WEEKLY /D $pp["DAY"] /RU $RunAsUser /RL HIGHEST /TN choco-upgrade-all-at /TR "%ChocolateyInstall%\bin\choco-upgrade-all.bat" /ST $RunTime /F
		    SchTasks /QUERY /TN "choco-upgrade-all-at"
            SchTasks /CREATE /SC WEEKLY /D $pp["DAY"] /RU $RunAsUser /RL HIGHEST /TN choco-upgrade-all-at-abort /TR "taskkill /im choco.exe /f /t" /ST $AbortTime /F
            SchTasks /QUERY /TN "choco-upgrade-all-at-abort"
	      }
		}
Start-Sleep -s 10
tools\chocolateyuninstall.ps1
$ErrorActionPreference = 'Stop'
$packageName = 'choco-upgrade-all-at'
$scriptDir   = "$(Get-ToolsLocation)\BCURRAN3"

SchTasks /Delete /TN choco-upgrade-all-at /F
SchTasks /Delete /TN choco-upgrade-all-at-abort /F

if (!(Test-Path "$ENV:ChocolateyInstall\lib\choco-upgrade-all-at-startup")) {
    Remove-Item "$ENV:ChocolateyInstall\bin\choco-upgrade-all.bat" -Force -ErrorAction SilentlyContinue
    Remove-Item "$ENV:ChocolateyInstall\bin\choco-install.bat" -Force -ErrorAction SilentlyContinue
    Remove-Item "$scriptDir\choco-upgrade-all.*" -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 Upgrade All at (Task) 0.0.6 141763 Tuesday, March 16, 2021 Approved
(unofficial) Choco Upgrade All at (Task) 0.0.5 44301 Sunday, May 6, 2018 Approved
(unofficial) Choco Upgrade All at (Task) 0.0.4.1 687 Tuesday, April 24, 2018 Approved
(unofficial) Choco Upgrade All at (Task) 0.0.4 328 Sunday, April 22, 2018 Approved
(unofficial) choco upgrade all at (Task) 0.0.3 2302 Friday, August 18, 2017 Approved
choco (unofficial) upgrade all at (midnight?) (Task) 0.0.2 604 Wednesday, May 24, 2017 Approved

A NOTE ON DEFAULTS:

  • If you don't specify any parameters, choco-upgrade-all-at defaults to running daily at 2AM and aborting at 4 AM. (My preference!)
  • Not specifying a TIME will always default to 2 AM. Not specifying an ABORTTIME will always default to TIME +2 hours.
  • When WEEKLY is specified but a DAY isn't, default first run will be a week from installation date; i.e. next week on whatever day of the week you installed the package.

IF UPGRADING FROM A VERSION EARLIER THAN 0.0.4:

Your old scheduled task will be deleted and replaced with default (mentioned above) parameters. To ensure choco-upgrade-all-at runs when you want it to, you should uninstall and reinstall with the settings you prefer.
I have not tested with useRememberedArgumentsForUpgrades, you might get daily still with your preferred time.

IF UPGRADING FROM VERSION 0.0.4 or 0.0.4.1:

You're old scheduled task will be kept. You will need to uninstall and re-install to take advantage of the new ABORTTIME feature.

IF UPGRADING FROM A VERSION EARLIER THAN 0.0.6:

It is HIGHLY advised you read the Release Notes/ChangeLog and run choco-upgrade-all -EditConfig to enable the new enhanced features.

CHANGELOG:

  • 0.0.7 - Fixed bug causing an error when there was no pre-existing icons when using the delete new icons feature, added detailed logging, added -ViewLog option, added report
  • 0.0.6 - Fixed wrong command in scheduled task. Added option to automatically delete newly created Desktop and Start Menu icons. Added option to run pre and post processing scripts. Added configurable arguments. Added ability to set default user profile. Edit C:\tools\BCURRAN3\choco-upgrade-all.config to enable the enhanced options. You can now run choco-upgrade-all from the command line to take advantage of these enhanced options. Added choco-install script which also uses the enhanced options. Added -EditConfig option to edit the config file. Changed default ABORTTIME to be TIME +2 hours.
  • 0.0.5 - Added abort stuck upgrades feature. "Um, why do I want this?" you're thinking. You want this because sometimes background package installations go wrong. "Go wrong?" you're thinking. Yes, there are a couple scenarios where a Chocolatey package installation/upgrade can hang: if a package needs input, if an AutoHotKey or AutoIt script fails, and all those times a program installer pops up a browser window to tell you "Thank you." These scenarios leave hung processes in the background with no way for you to easily interact with them (They're in the background!). This means they are taking up memory resources for no reason and might cause problems installing other packages or programs. If you knew there was a hung process, you could manually stop the task, but who wants to check every day? This will automate checking and stopping any Chocolatey package hung tasks at the time you specify. I recommend setting it to a time an hour or two after you run your updates.
  • 0.0.4.1 - Fixed compatibility with Windows 7 and 8 machines by using SchTasks.exe for everything and not using the Windows 10/Server 2016 only Get-ScheduledTask cmdlet. Removed PowerShell v4/v5 dependency.
  • 0.0.4 - Added option to run weekly.

ROADMAP

    • Move the ABORTTIME feature into the config file; i.e. Start-Job, Start-Sleep ABORTIME, Stop-Job
Discussion for the (unofficial) Choco Upgrade All at (Task) Package

Ground Rules:

  • This discussion is only about (unofficial) Choco Upgrade All at (Task) and the (unofficial) Choco Upgrade All at (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 Upgrade All at (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