Windows 10 Toast Notification Script Update: Run ConfigMgr applications directly from the action button

Introduction

Another update to the Windows 10 Toast Notification Script is a reality. Now being on version 1.6.

The feedback and questions related to the Windows 10 Toast Notification Script keeps coming and that’s amazing!

In my last post and update of the script, I added the option to natively and with help of a custom protocol in Windows, to run task sequences directly from the action button.

Since then, I was asked if the script is able to launch application directly from the action button as well, and sure thing. I just added that capability to the script and the details are explained below.

What’s New

  •   1.6 – Added new option to run applications (ApplicationID) directly from the toast notification action button. Enable the option <RunApplicationID> in the config.xml
    • Created Display-ToastNotification function
      • Displaying the toast notification as been trimmed and merged into its own function
    • Created Test-NTSystem function
      • Testing if the script is being run as SYSTEM. This is not supported and will prevent the toast notification from being displayed
    • Converted all Get-WMIObject to Get-CimInstance
      • Get-WMIObject has been deprecated and is replaced with Get-CimInstance

Config.xml

The new option, which enables you to run applications directly from the Install/Action button, is highlighted below.

To enable the option, simply configure RunApplicationID to Enabled=”True” and specify the Application ID of the application in the Value field: Value=”ScopeId_A9117680-D054-482B-BC97-532E6CBD0E6B/Application_fd55f35c-4e34-4490-a3ec-ee0b79233ec6″

For your convenience, I have included a new example of the config.xml in the download: config-toast-officeupgrade.xml

Application ID

The ID of an application can be found using Powershell or by browsing the Software Center (and probably with other means too). Both of the options requires that the application in question is deployed to the device.

Powershell

Run below line of Powershell, inserting the name of the application.

The output will be similar to below illustration:

Software Center

The ID of the application can also be found via Software Center by browsing the application in question and using the Share button, also as illustrated below.

Note that it’s only the part after the “=” sign which is needed. Not the entire link.

How does it work?

In order for this to work, you need to create a custom protocol in Windows 10. The easiest approach is to install this through the .MSI I provide in the download:

Windows 10 Toast Notification Script Custom Action Protocols.msi

  • Note: This is now coming in a version 1.2.0. If you installed my previous version, you should be able to simply upgrade the installation to include the new files.

ToastRunApplicationID Protocol

The installation currently comes with three custom protocols. The one of interest in this example, is the one called ToastRunApplicationID. The installer creates below registry entries, which creates the custom protocol:

This enables us to use ToastRunApplicationID: as an action in the config.xml, which in return launches the referenced ToastRunApplicationID.cmd.

Local Files

The installation also drops some local files into ProgramData\ToastNotificationScript. The current content is illustrated below and currently consists of 5 files:

  • Run-PackageID.ps1 (not used in this example)
  • ToastReboot.cmd (not used in this example)
  • ToastRunPackageID.cmd (not used in this example)
  • Run-ApplicationID.ps1
  • ToastRunApplicationID.cmd

Run-ApplicationID.ps1

This is the new script doing the magic in this scenario. The script is included in the download, and is being installed onto the device with the installation of Windows 10 Toast Notification Script Custom Action Protocols.msi.

The script is somewhat self explanatory, and is triggering the installation of the application via WMI.

Process Explained

The process may seem complicated, but it’s not. I will try to explain the sequence of actions here:

  1. Toast Notification Script run and tattoos the registry with the ID of the application into HKCU:\SOFTWARE\ToastNotificationScript
  2. When clicking the action/install button of the toast notification, the protocol ToastRunApplicationID: is being initiated
  3. This launches the ToastRunApplicationID.cmd, which again launches the final Powershell script: Run-ApplicationID.ps1
  4. Run-ApplicationID.ps1 dynamically picks up the ApplicationID from the registry and runs the corresponding application directly on the device
    • This makes sure you never have to edit any of the local files. Only the config.xml will ever need editing

Use Case Inspiration

OS Upgrade with Powershell App Deployment Toolkit

So, to keep it short. What I’m doing here, is to have the Install now button directly launching an application based on PSADT. The application based on PSADT, is in return launching the In-Place Upgrade Task Sequence.

The sequence is as following:

  1. Toast Notification pops up
  2. Install now button is launching the application based on PSADT
  3. PSADT is then launching the actual In-Place Upgrade Task Sequence
    1. This via the awesome customization that PSADT provides

If anything needs further explaining, don’t hesitate to reach out to me on Twitter or in the comments section down below.

Download

>> https://gallery.technet.microsoft.com/Windows-10-Toast-9f228eb1 <<

More info

26 thoughts on “Windows 10 Toast Notification Script Update: Run ConfigMgr applications directly from the action button”

  1. Amazing work, as previously mentioned in earlier version I did some modification and also used that function to trigger application

    Your version 1.6 is more complete and I want to follow your version-control and not mine so will use this when I have the time to deploy it 🙂

    Currently I use several version if your toast on the place I work and this is from production environment right now:

    I have a toast to remind people to update BIOS Firmware update on all our devices. We use Dell hardware

    I also have the last version but modified toast that will notify people about a important application software upgrade – a software from Check Point that is actually “resetting” the network adapter so thats why some custom-made information is required and also let the user decide when they are ready to be disturbed 🙂

    And the next big thing, our InPlace upgrade TS that we going to do from W10 1809 to 1909. No rush with this yet. But I am also using custom made PSADT that will be triggered with your toast.

    Almost forgot! Since Corona we are forced to work from home actually and when that policy applied we had to make sure VPN is working for everyone, so with that I made a reminder about changing password if it will expire within 14 days with your toast. and Alot of people got this toast and changed their password and we avoided hassle with the VPN from users that were frustrated at home when VPN did not work 🙂

    So yea, your work have helped me alot and is widely used where I work, a quite big authority in Sweden 🙂

    Any plans to maybe have this on Github in a public repo?

    //Andreas

    Reply
    • This is awesome Andreas. Thank you for letting me know all of this. Much appreciated. And yes, due to the deprecation of TechNet Gallery, I will move the script into GitHub soon enough 🙂

      Reply
  2. Don’t know if it is already possible, but can you add an action to the action button where if you click it opens your default browser and redirects you to a specific URL set in the XML? Just so we can nag our users to read important messages on the intranet during these special times.

    For now I’ve implemented three different scenario’s of your notification and it works like a charm.

    Reply
        • I would assume that https:yourwebsite.com should work too, but I haven’t tried (seeing this is a protocol based action as well, and should launch the default browser 🙂

          Reply
          • Unfortunately nothing happens and since Edge is not our default browser using Edge as the action first popups a message from Microsoft to set Edge as your default browser or to create a profile. This is not the desired behavior for now.

          • I’m sure you could do something with another custom protocol and even decide very specifically which browser you would open a given link in. What browser is your default? 🙂

  3. Another custom action incoming… 🙂

    It’s not that important, but it would be a nice to have feature when clicking on a button redirects you to a webpage with more information using the default browser (or a specific one like Chrome if that is not the default)

    Reply
  4. I’m using this script to install an application and running the script on a schedule. If the users clicks install and installs the app, the toast notification will pop up again during the next scheduled time anyway. Is there a way for the script to detect that the application has already been installed and to stop running? Its a bit annoying for the user to continually be asked to install the app when they have already done so or perhaps I am not using the scripts correctly?

    Reply
    • This is something I would manage with the collection you are deploying the toast notification script to. Hence the collection only consists of devices which doesn’t have the said app installed already, so once installed, the devices moves out of the collection and therefore is no longer a target of the deployment of the toast 🙂

      Reply
  5. Hey Martin, I’m running the script and nothing happens for some reason”

    PS C:\Support\Windows 10 Toast Notification – Run ConfigMgr Apps and TS from the action button> .\New-ToastNotification.ps1 -config config-toast-officeupgrade.xml
    VERBOSE: Running supported version of Windows. Windows 10 and workstation OS detected
    VERBOSE: The registry key for determining if toast notifications are enabled does not exist. The script will run, but toasts might not be displayed
    VERBOSE: Successfully loaded config-toast-officeupgrade.xml
    VERBOSE: Loading xml content from config-toast-officeupgrade.xml into variables
    VERBOSE: Successfully loaded xml content from config-toast-officeupgrade.xml
    VERBOSE: RunApplicationID set to True. Will allow execution of ApplicationID directly from the toast action button
    VERBOSE: Running Write-ApplicationIDRegistry function
    VERBOSE: ApplicationID: ScopeId_C413C893-E344-4206-96C1-F667AB423811/Application_4fc206d7-40ad-4e50-9110-f9275c11c9ca was found in WMI as deployed to the client
    VERBOSE: Writing the ApplicationID to registry

    RunApplicationID : ScopeId_C413C893-E344-4206-96C1-F667AB423811/Application_4fc206d7-40ad-4e50-9110-f9275c11c9ca
    PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE\ToastNotificationScript
    PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE
    PSChildName : ToastNotificationScript
    PSDrive : HKCU
    PSProvider : Microsoft.PowerShell.Core\Registry

    VERBOSE: Greeting with given name selected. Replacing HeaderText
    VERBOSE: Running Get-GivenName function
    VERBOSE: Given name retrieved from Active Directory
    VERBOSE: Creating the xml for displaying both action button and dismiss button
    WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
    WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
    VERBOSE: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
    VERBOSE: All good. Displaying the toast notification

    I can’t find “ToastEnabled” key under “HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications”.
    Can this be the issue?
    I’ve signed the scripts under C:\ProgramData\ToastNotificationScript with our cert too.

    Reply
      • Hmm, does the toast notification go straight to the action center perhaps? Do you have focus assist enabled? Is this happening when using both Software Center or Powershell as the notifying app?

        Reply
  6. Hi Martin,
    I am having some issues that the restart button does not restart the computer. It says that ” You will need a new app to open this toastreboot link. I have enable only Powershell. Thank you for any help.

    Reply
  7. Hello Martin,
    I would like to ask you if you know an easy way to inform the user to free up disk space in case they have less than 5GB available?
    I saw some articles that will apply on PCs in certain SCCM collection, but it does not work very well.
    I am thinking for something as a scheduled task for example that will run a script checking the free disk space that does not rely on SCCM agent.

    Reply
    • Hey, you can leverage my toast notification to send out a notification to those devices being on less than 5Gb available. Finding devices that has less than 5GB available can be done via the proper collections. Is that something you are looking for?

      Reply

Leave a Reply to Jason Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.