Notices: This section not yet converted to new layout. Download stats are rolling back out.

choco upgrade all at startup (Script)

2017.01.10

Package test results are passing.

This package was approved by moderator flcdrg on 1/11/2017.

Create a Scheduled Task to keep all Chocolatey Packages up-to-date

FEBRUARY 23, 2016 / DANIEL S

Rebuilding your PC is always a drag, even with useful utilities like Ninite.

I recently created a PowerShell DSC script that I can use whenever I need to rebuild my PC. As part of that, I used the cChoco provider to automatically install applications using Chocolatey. I’ll be writing a blog post with more details shortly.

That’s a great way to get the applications installed, but not for keeping them up-to-date. Chocolatey allows you to run ‘choco upgrade all’ manually to do this:

Screenshot of choco upgrade all

Rather than manually create the scheduled task to automate this, I created this short PowerShell script:

$chocoCmd = Get-Command -Name 'choco' -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Select-Object -ExpandProperty Source
if ($chocoCmd -eq $null) { break }
$taskAction = New-ScheduledTaskAction –Execute $chocoCmd -Argument 'upgrade all -y'
$taskTrigger = New-ScheduledTaskTrigger -AtStartup
$taskUserPrincipal = New-ScheduledTaskPrincipal -UserId 'SYSTEM'
$taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Trigger $taskTrigger -Settings $taskSettings
Register-ScheduledTask -TaskName 'Run a Choco Upgrade All at Startup' -InputObject $task -Force

The script will:

  • Locate the choco.exe binary (It’ll quit if it can’t find it in the path)
  • Set up a scheduled task that runs said binary at system startup

Note that this script will only work on Windows 8 and newer machines, because it relies on the *-ScheduledTask cmdlets.

To install choco upgrade all at startup (Script), run the following command from the command line or from PowerShell:

C:\> choco install choco-upgrade-all-at-startup

To upgrade choco upgrade all at startup (Script), run the following command from the command line or from PowerShell:

C:\> choco upgrade choco-upgrade-all-at-startup

Files

Hide
  • tools\chocolateyinstall.ps1 Show
    $chocoCmd = Get-Command -Name 'choco' -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Select-Object -ExpandProperty Source
    if ($chocoCmd -eq $null) { break }
    
    # Settings for the scheduled task
    $taskAction = New-ScheduledTaskAction –Execute $chocoCmd -Argument 'upgrade all -y'
    $taskTrigger = New-ScheduledTaskTrigger -AtStartup
    $taskUserPrincipal = New-ScheduledTaskPrincipal -UserId 'SYSTEM'
    $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8
    
    # Set up the task, and register it
    $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Trigger $taskTrigger -Settings $taskSettings
    Register-ScheduledTask -TaskName 'Run a Choco Upgrade All at Startup' -InputObject $task -Force

Virus Scan Results

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.

Dependencies

This package has no dependencies.

Maintainer(s)

Software Author(s)

  • Daniel Streefkerk

Tags

Version History

Version Downloads Last updated Status

Discussion for the choco upgrade all at startup (Script) Package

Ground rules:

  • This discussion is only about choco upgrade all at startup (Script) and the choco upgrade all at startup (Script) 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 choco upgrade all at startup (Script), 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