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:

387,967

Downloads of v 2023.5.26:

69,283

Last Update:

19 Nov 2023

Package Maintainer(s):

Software Author(s):

  • Bill Curran

Tags:

bcurran3 unofficial choco upgrade startup config schtasks scheduled task

(unofficial) Choco Upgrade All at Startup (Task)

  • 1
  • 2
  • 3

2023.5.26 | Updated: 19 Nov 2023

Downloads:

387,967

Downloads of v 2023.5.26:

69,283

Maintainer(s):

Software Author(s):

  • Bill Curran

(unofficial) Choco Upgrade All at Startup (Task) 2023.5.26

  • 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:

Package Scanner thinks there should be one more file to scan than there actually was, this is an issue with Scanner and not this package.

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

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

>

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

>

To uninstall (unofficial) Choco Upgrade All at Startup (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-startup -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-startup -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-startup
  win_chocolatey:
    name: choco-upgrade-all-at-startup
    version: '2023.5.26'
    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-startup' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '2023.5.26'
end

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


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

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


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

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


DO YOU WANT TO UPGRADE YOUR CHOCOLATEY PACKAGES EVERY TIME YOUR COMPUTER BOOTS?

YOU JUST FOUND THE EASY WAY!

This package creates a Windows Scheduled Task to run "choco upgrade all -y" with enhanced options every time your computer boots.

Please understand your computer boot time will increase. If you reboot daily, you'll probably never notice. If you reboot infrequently, you'll notice a slow down as packages are downloaded and updated/installed, especially if you have a slow Internet connection. Because of this choco-upgrade-all-at-startup is pseudo-deprecated and pseudo-superseded by choco upgrade all at which allows you to set a time to run "choco upgrade all -y" every day in the wee hours of morning while you're happily dreaming of owning a supercomputer instead of twiddling your thumbs waiting for your "slow" computer to boot up. Otherwise it works wonderfully at keeping your Chocolatey installed programs up to date.

USAGE INSTRUCTIONS:

  • You can do nothing and it will run at startup when on AC power.
  • 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-startup settings.

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

SYSADMINS: I recommend use of choco-upgrade-all-at-startup for notebook/laptop users who tend to shut down their computers at night and thus miss scheduled updates/maintenance such as choco upgrade all at (in the wee hours of the morning).

IF UPGRADING FROM A VERSION EARLIER THAN 2021.03.15:

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

PACKAGE NOTES

If you find choco-upgrade-all-at-startup 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-startup'
$toolsDir     = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$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 if it exists from versions 2017.01.10 and earlier
$ErrorActionPreference = 'SilentlyContinue'
$GotTask = (&schtasks.exe /query /tn "Run a Choco Upgrade All at Startup") 2> $null
$ErrorActionPreference = 'Stop'
if ($GotTask -ne $null){
    &schtasks.exe /DELETE /TN "Run a Choco Upgrade All at Startup" /F
   }

# Configure the scheduled task
$ErrorActionPreference = 'SilentlyContinue'
$GotTask = (&schtasks.exe /query /tn "choco-upgrade-all-startup") 2> $null
$ErrorActionPreference = 'Stop'
if ($GotTask -ne $null){
# Change existing task to run new batch file 2021.03.13+
     &SchTasks /CHANGE /TN "choco-upgrade-all-startup" /TR "%ChocolateyInstall%\bin\choco-upgrade-all.bat"
   } else {
# create new scheduled task to run at startup   
     SchTasks /Create /SC ONSTART /RU SYSTEM /RL HIGHEST /TN "choco-upgrade-all-startup" /TR "%ChocolateyInstall%\bin\choco-upgrade-all.bat" /F
   }
if (Get-IsWin10){
	$TaskSettings=New-ScheduledTaskSettingsSet -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Hours 2) -RunOnlyIfNetworkAvailable -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 5) -StartWhenAvailable
	Set-ScheduledTask -TaskName choco-upgrade-all-startup -Settings $TaskSettings
}
Write-Host "Now configured to run ""choco upgrade all -y"" with enhanced options at Windows startup." -Foreground Magenta 
tools\chocolateyuninstall.ps1
$ErrorActionPreference = 'Stop'
$packageName = 'choco-upgrade-all-startup'
$scriptDir   = "$(Get-ToolsLocation)\BCURRAN3"

SchTasks /Delete /TN “choco-upgrade-all-startup” /F

if (!(Test-Path "$ENV:ChocolateyInstall\lib\choco-upgrade-all-at")) {
    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 Startup (Task) 2023.05.26-pre 2321 Friday, May 26, 2023 Exempted
(unofficial) Choco Upgrade All at Startup (Task) 2023.05.15-pre 180 Tuesday, May 16, 2023 Exempted
(unofficial) Choco Upgrade All at Startup (Task) 2023.05.10 98970 Thursday, May 11, 2023 Approved
(unofficial) Choco Upgrade All at Startup (Task) 2021.03.15 149857 Monday, March 15, 2021 Approved
(unofficial) Choco Upgrade All at Startup (Task) 2018.08.23 54251 Thursday, August 23, 2018 Approved
(unofficial) Choco Upgrade All at Startup (Task) 2018.01.30 9453 Tuesday, January 30, 2018 Approved
choco upgrade all at startup (Script) 2017.01.10 3499 Tuesday, January 10, 2017 Approved

CHANGELOG:

  • 2023.05.26 - added new defaults for Win10+ computers (-DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Hours 2) -RunOnlyIfNetworkAvailable -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 5) -StartWhenAvailable)
  • 2023.05.10 - 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
  • 2021.03.13 - 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 new run choco-upgrade-all from the command line to take advantage of the enhanced options. Added choco-install script to work with the same enhanced options. Added -EditConfig option to edit the config file.
  • 2018.08.22 - 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.
  • 2018.01.30 - simplified, standardized, description updated, uninstall added
  • 2017.01.10 - original release

ROADMAP

  • Re-write task creation using PowerShell cmdlets (instead of using schtasks) for advanced options such as enabling run on battery, limited execution time, only when a network is available, etc..
Discussion for the (unofficial) Choco Upgrade All at Startup (Task) Package

Ground Rules:

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