Windows 10 Toast Notification Script Update: Custom notification app and more built-in prevention from disabling toast notifications

Introduction

It’s been a while since the last update on this script. I admit that. Better late than never, I guess.

This update brings a slight improvement to the looks of the toast notifications, and (almost) definitely removes the option for the end-user to disable the notifications as well.

Also, I was wondering about naming the script differently. The script surely works with Windows 11 too, but seeing the entire toast framework was introduced with Windows 10, and Windows 11 behind the scenes is still appearing as version 10.0, I will stick with the current name.

What’s New

  • 2.3.0 – Added the Register-CustomNotificationApp function
    • – This function retrieves the value of the CustomNotificationApp option from the config.xml
    • – The function then uses this name, to create a custom app for doing the notification.
      • – This will reflect in the shown toast notification, instead of Software Center or PowerShell
      • – This also creates the custom notifcation app with a prevention from disabling the toast notifications via the UI

Config.xml

The addition of the new option to create a custom notification app, requires you to update your existing config.xml files. The changes to the config.xml file is highlighted below, and the results are shown in the picture above.

Register-CustomNotificationApp

The magic lies within this function in the script. Bits and pieces are borrowed from Mr. Trevor Jones @ https://smsagent.blog.

What I do differently, is to write the details into HKCU, so the script – once running in user context – is able to write to the relevant area of registry.

I also add an icon to the notification app, which in this scenario is a small cogwheel. See the header-image for the exact illustration.

Prevention of disabling Toast Notifications

The (almost) definitely prevention from disabling the toast notifications, comes from the ‘ShowInSettings’ DWORD value in registry. Almost because this is written to HKCU, and users with knowledge of registry, can obviously modify this themselves.

This is the area of registry, which the script creates automatically for you, based on the content of the config.xml.

Download

Download everything fromΒ GitHubΒ here:Β https://github.com/imabdk/Toast-Notification-Script

If any questions, please leave them down below and I am happy to assist with any issues.

ENJOY πŸ™‚

34 thoughts on “Windows 10 Toast Notification Script Update: Custom notification app and more built-in prevention from disabling toast notifications”

  1. Martin, thank you for great work.
    I was wondering why other xml config files have both UseSoftwareCenterApp and CustomNotificationApp set to ‘True’
    I am trying to run some configs manual to test and getting an error:
    Error. You can’t have both SoftwareCenter app set to True AND CustomNotificationApp set to True at the same time. Check your config
    I can run the script if i change SoftwareCenter to False.
    Can and should i have both set to true when running from SCCM?
    Thank you.

    Reply
    • Right, that just me forgetting to reset those values back to False. Ideally and with the new version, you set both Software Center and PowerShell to False, and configure CustomNotificationApp to True and with the desired value. πŸ™‚

      Reply
  2. Hi Martin, at the beginning thank you so much for this amazing work. I want to ask because I did not test your script yet, can the scrip allow us to change the logo to the company logo? Can we add more than one portion to the user for restart like , 1 hour, 2 , etc. ? Finally can we custom the message to meet the app or the deployment we use it for?

    Reply
  3. Hi Martin, first of all, a big thank you for this! Would there be a way to get some kind “confirmation message/button” after user press “Install” (OS Upgrade)? Like: “Have you saved all your work before continuing? Press “yes” to continue OS Upgrade”. Thank you.

    Reply
    • Yeah, you can leverage PowerShell App Deployment Toolkit to add even further user-friendliness to the process. I have a blog post covering that as well. So instead of launching the OS directly on the install button, the install button launches PSADT that have that extra confirmation you seek. Search for PowerShell App Deployment Toolkit on my blog πŸ™‚

      Reply
  4. Hi Martin, first of all, a big thanks for your efforts, this is amazing work. for some reason when I try to test it by removing your website from the Toast notification, through some errors, also, can I change the time and give the user an option to snooze it if they are in the middle of something?
    Please advise

    Thanks,
    Matt

    Reply
  5. Hi Martin –

    I am getting the toast notifications but I am iMAB.DK NOTIFICATIONS and that I have a new notification, no hero images or additional text. Any thought?

    Reply
    • Have you made any changes to the config.xml you are using? Run the New-ToastNotification.ps1 directly from the download, without changing anything in any config.xml. verify this works and make changes from there. The log file in appdata\ToastNotificationScript is helpful to paste here too.

      Reply
  6. Hi Martin
    first of all – thx for the amazing script. you should get an award for it πŸ˜€

    1 recommendation. can you add in your github maybe following line that every new “customer” can benefit of seeing which user as executed the notification.ps1. here are my code adaptions:

    function Test-NTSystem() {
    $currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
    if ($currentUser.IsSystem -eq $true) {
    Write-Log -Message “Script is initially running in SYSTEM context. Please be vary, that this has limitations and may not work!”
    $true
    }
    elseif ($currentUser.IsSystem -eq $false) {
    $currentUserName=$currentUser.Name
    Write-Log -Message “Script is initially running in USER context – $currentUserName”
    $false
    }
    }

    the your logfiles will also contain the user who has executed it like this..

    2022-02-02 15:05:18 INFO: Script is initially running in USER context – DomainHeros\TonyStark

    2nd and quite more important for me… i do have an issue where i am abit frustrated yet.
    when i execute the command lines in an user context running powershell ISE i can see the Toast but when i am running the same staff as scheduled task etc i can see the success execution within the logfile but there is no toast notification visible on the win10 users host.. any ideas? the funny stuff, i can also execute it in MEMCM as package but not in a way that i can use it in emergency cases etc direct via scripting… remote sessions etc…

    pls get in contact with me. it seems to be that i am a noob in this case πŸ˜€

    Reply
    • Hey, thank you for your suggestion. I’ll add that into a future release.
      In regards to your obstacles with a scheduled task. Have you had a look on my (very limited, I know) documentation included in the download? There are clear instructions on how to get this to work with a scheduled task.
      Also, the script is confirmed to work with applications, packages/programs and task sequences in ConfigMgr. It does not work with the Run Script feature πŸ™‚

      Reply
  7. Hi Martin,
    Thank you for this amazing work.
    I am working on it to test if I can use it to upgrade from 1909 to 21H2.
    And most part seems ok so far but I have got a problem when comes to the toast notification.
    I have created a script to create the Task scheduling so that every time a user logon, it triggers a popup.
    I integrate the package to my SCCM and downloaded to my VM.
    Yes, task scheduling is created but the popup is not working.
    I took my script and created the task scheduling by running the script manually and toast notificaiton is working because when I run m it manually, it runs as user.
    I see above oyu mention in your documention but you didn’t mention where to get it.
    can you help please on this?
    Much appreciate

    Reply
  8. Hi Martins.

    First of all thanks for this script.

    I would like to know if there is any way of testing the OSUpgrade toast without the upgrade available.

    I wanted to customize it and see it before applied in out environment. Can you help?

    Thanks.

    Reply
    • Yeah, you simply have disable the various options in the .xml, so you revert to displaying a default toast notification. With that, you can verify the looks of the toast before using in production. I encourage you to atleast deploy the new OS to yourself or test devices, to test the complete flow.

      Reply
  9. Hi Martin,
    Thanks for the amazing script πŸ™‚
    Is there a way to add a countdown time for the restart function and at the end of the countdown to actually restart the PC ?
    Thanks,
    Iulian

    Reply
    • Thank you. Only if you make something yourself. Should be doable with PowerShell, but it’s not something that’s built in. πŸ™‚

      Reply
  10. Hi Martin

    Thank you for the great work, I just have question regarding the script of Register-CustomNotificationApp, after run this script, I suppose to see my app show in the Notifications & Actions in Windows 10 Settings?

    Thanks

    Reply
    • No, the notification app will not be visible in the UI, but you can use it in your toast notification script config.xml πŸ™‚

      Reply
      • Thank you for quick response, but in the original blog from Mr. Trevor Jones, he mentioned “The ShowInSettings parameter determines whether the app can be seen in Settings where the user can turn notifications on or off for the app.”, so what’s the difference here?

        Thanks

        Reply
  11. Hello All,
    I am using the script via Task Schedular the problem is with Windows 10 20H2 patch where I an unable to use the toast notifications for unsupported Apps.

    Reply
  12. Great script. I do have a question in regards to rebooting. I have been tasked to ensure systems are rebooted weekly but I want to give the users warnings and such but also force it if they don’t follow through. Would it be possible to add a deadline for a reboot and if the user does not reboot it can it be forced on them? Would it be best to call an app\package? Thanks!

    Reply
    • Then you will have to extend the script, to create a scheduled task for you instead. Currently, the only action the script has in that regard, is to run shutdown. Hence you will need to build something on your own πŸ™‚

      Reply
  13. @martin Bengtsson

    amazing work ! finally i found a toast-script that worked !!

    Great Job !!!

    One question, is it possible to start a batch-file from a action button ?

    Reply

Leave a Comment

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