Putting it All Together Using Winget (Notepad++ Example)

What

Winget is a command line tool to manage applications on the Windows 10 and 11 platform.

When/Why

We've covered all of the building blocks, so now you know how to install, upgrade and remove apps using winget.  But, those three actions fit best together in just one payload/fileset.  In this article we'll discuss (and share) the fileset for doing just that...without touching one bit of code!

How

We won't need any code in this example, because we don't need to modify code to install/upgrade/remove any app that is available in the Microsoft repository.  At least, we don't need to do that if you have the following Notepad++ example payload/fileset: Notepad++.fileset.zip

But before we start using this fileset (It works great with a Kiosk association), let's take a look at the components, and how you use it.

There are three scripts in the fileset, as you can see below:

There are three scripts, because we want three distinct things to happen.  On install (the Activation script), we want FileWave to install Notepad++.  On a periodic basis (the verification script), we want FileWave to attempt to upgrade Notepad++ (if there is an upgrade available).  And finally, if we remove the association, or the customer chooses to uninstall from the kiosk, then we want to run the pre-uninstallation script to remove Notepad++.

Running the upgrade call everyday may be a bit excessive, but we used it in the example because it was simple to understand.  Using the fileset to control a scheduled task may be another solution that could be used.

So now we know about all of the bits and pieces, but you may be asking how we don't have to edit code to make this work?  We do this by simply passing a launch argument to each script.  The script replaces a variable with this launch argument, and it is all done.

You set a launch argument in "Get Info" within the fileset contents (shown below):

There are three scripts in this payload/fileset, and each has its own launch argument.  Any time you modify or duplicate this fileset, you'll want to modify that launch argument for each AND change the destination folder name so that your filesets don't step on each other.

Using this Fileset for Another Winget Package

Using this fileset for another piece of software is very simple...just do the following steps:

  1. Find the ID of the package you want to install using the winget search command (reference), an example would be Mozilla.Firefox
  2. Duplicate this example fileset
  3. Rename the duplicated fileset appropriately
  4. In the contents of the fileset, change the folder name within the scripts folder to something meaningful and unique (so that multiple filesets don't compete)
  5. Set the launch argument for EACH of the three scripts to the ID you identified in step 1...in our example, Mozilla.Firefox
  6. Save your changes
  7. And ALWAYS test, test, test before deploying to production