WinGet installation as a snapin
-
Hi, everyone.
Hopefully this is useful for a few people.
I’ve written a wrapper around with Python to be able to run the WinGet command from the Snap-In tasks with some commands forced (accepting agreement, source, ect. when installing.
I’ve created this due to WinGet changing its location based on its version, no doubt there was an easier way to do this, but figured I’d try learning something different with Python.It is fairly easy to use, and you would need to convert the script into an executable with a program such as Auto-Py-to-Exe so it doesn’t have any Python requirements on the host device.
After the script is converted into a binary, you can either re-name it, use it in a snap-in pack and call it like you would regular Winget commands.
The only additional argument is the logging to a file. If calling the script without logging it is just outputted to the standard output.
Otherwise installing and logging to the fog.log for example.PyWinGet.exe --log c:\fog.log install notepad++ -s winget
When logging, it needs to be set before the WinGet commands.
Anyway, it can be found in my Fog Snap in folder on GitHub.
https://github.com/mediocreatmybest/FOG-O-Matic/blob/main/FOG-Snapins/PyWinGet.py
FYI, Winget isn’t the best program to pipe into a text file due to its usage of progress bars that you can’t switch off, but it is still readable.
-
Copy and pasted for the Chocolatey wrapper ChocolatePy
Pretty much same same. Just Chocolatey won’t neccessarily give an error on the exit code on failure if a program is already installed.https://github.com/mediocreatmybest/FOG-O-Matic/blob/main/FOG-Snapins/ChocolatePy.py