Zend certified PHP/Magento developer

How do you programmatically check if there are updates to your installed programs with winget?

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.