1

I want to upgrade a specific package but only if its not installed. I run an update script that keeps all my pc's up2date. cup all and choco upgrade all work well for exactly this purpose, but does not handle apps that install locally under user appdata, like f.lux. So I do this to traverse the different users and install those apps that do user space install:

$orgUserProfile=$Env:USERPROFILE
$orgLocalAppData=$Env:LOCALAPPDATA
$Env:USERPROFILE="C:\users\Alex"
$Env:LOCALAPPDATA="${Env:USERPROFILE}\AppData\Local"
# Installed to c:\Users\Alex\AppData\Local\SourceTree 
choco upgrade sourcetree
choco upgrade f.lux
$Env:USERPROFILE="C:\users\Lisa"
$Env:LOCALAPPDATA="${Env:USERPROFILE}\AppData\Local"
# I'm not sure updates will work for lisa, not sure I want to force it, it seems choco is not multi-user
choco upgrade f.lux
$Env:USERPROFILE=$orgUserProfile
$Env:LOCALAPPDATA=$orgLocalAppData

cup all

However on some of my PC's I don't have sourcetree, f.lux installed already and I don't want my upgrade script to install them.

Is there a simple way to make chocolatey only upgrade if its already installed? So I don't have to parse the list manually

PS:

Here's like the opposite question

Here's the choco upgrade documentation

1

This does not exist currently, but follow https://github.com/chocolatey/choco/issues/1646 - if that releases in the planned version, that will be part of v0.10.12.

  • Ah, great info, thank you for the link to the issue, I didn't think to check there first. – arberg Dec 16 '18 at 21:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.