1

I've spent a ridiculous amount of time trying to make use of winget.

If I simply run winget upgrade, or winget upgrade <package> for each program I care about, it not only checks if there is an update, but actually updates, which frequently means it will get perpetually stuck waiting for a prompt of some kind. Not all installers just run smoothly and make the update. I know this from experience.

Since actually updating programs through winget requires me to sit there and actively deal with it (the flag to "skip prompts" does not work), I want to only check whether there are updates, so that I can script logic to determine if I should notify myself about having to run the winget upgrade commands.

But if I do winget list, while it does list the information I want (program names, installed version, available version), it does this as a for-human text output, which is obnoxious to try to parse for my script. It does not support outputting as JSON. (And I'm in cmd.exe context, from necessity -- not PowerShell.)

However, there is a feature called "export", which ostensibly does exactly what I want: outputs a JSON file with the program names and... no versions. However, it has a secret flag called --include-versions. However:

winget export -o "tmp.txt" --include-versions

... only includes the currently installed version -- not the "available version" column! This makes it impossible to use this JSON output to determine whether any given program has an available update!

What on Earth were they thinking when they designed this system? What could they be intending that I'm supposed to do to learn this info? I actually have to figure out a way to regexp the for-human text output after all? It feels so wrong and so stupid, especially when they have a literal "export to JSON" feature which avoids the crucial information of the "available version".

As usual: I must be missing something.

Valantine
  • 11
  • 2
  • 2
    Have you tried WingetUI, a graphical interface for Winget? https://www.marticliment.com/wingetui/ This might be easier to use to *review* items without immediately *updating*. – DrMoishe Pippik May 04 '23 at 21:27
  • @Destroy666 The whole point was to script this. As such, a GUI program is the opposite of what I need. – Valantine May 04 '23 at 21:55
  • I didn't recommend a GUI – Destroy666 May 04 '23 at 21:55
  • @Destroy666 "v1.4.10173". Please see my comment on the below answer; I was wrong about a small detail but it doesn't change what I basically ask about. – Valantine May 04 '23 at 21:56
  • “What on Earth were they thinking when they designed this system? What could they be intending that I'm supposed to do to learn this info?” - **You really should remove these unanswerable questions from your question.** – Ramhound May 04 '23 at 23:24
  • Also, if you feel the output formats should be more parsing-friendly then winget is on GitHub: https://github.com/microsoft/winget-cli Or you could ask a more specific question about your batch parsing attempts of it instead. – Destroy666 May 04 '23 at 23:33
  • @Destroy666 Github doesn't allow registration. It's been impossible for me to register (and keep for more than a few seconds) an account there for many years now. – Valantine May 05 '23 at 14:00

1 Answers1

1

Unless your winget is bugged or something (it's not for me on latest 1.4.10173 version):

winget upgrade without any switches by default just lists packages that could be updated.

winget upgrade --all is the command to actually upgrade everything.

Documentation also confirms this behavior.

To identify which apps are in need of an update, simply use upgrade without any arguments to show all available upgrades.

For a single package you can also use winget list "packagename" or winget list package.id.

All of the mentioned commands list Name, Id, Version, Available, Source columns. The data is separated with varying number of spaces, so advanced parding with batch will be required if you have to use that.

Destroy666
  • 5,299
  • 7
  • 16
  • 35
  • Well, it does it in the same "for-human" text output. Not easily parseable. My point stands. – Valantine May 04 '23 at 21:54
  • 1. I asked the question but you seem to not read it. 2. I explicitly mention that I'm NOT in PowerShell context. – Valantine May 04 '23 at 22:15
  • I missed that, my bad (even though not sure why you wouldn't be able to use PS, what about other installable CLI tools?), but it's still possible to parse with batch, not as easily, but you won't find anything better. – Destroy666 May 04 '23 at 22:20
  • Well, there's also `winget list [packagename]` for a single package, but it also doesn't look like perfect material to parse. I'll add info about it to the answer though – Destroy666 May 04 '23 at 22:22
  • `winget list [packagename]` just gives the same output as `winget list`, so I don't know what you mean by that. And Powershell has massive issues which are too complex to mention here. – Valantine May 05 '23 at 13:59