Notifications - popups vs history


pokeefe0001

Well-known member
Member
VIP
Local time
5:02 PM
Posts
219
Location
Pacific Northwest USA
OS
Windows 11
There seem to be two mostly unrelated aspects of Windows notifications: the popups that display for a few seconds (Are those "toasts"?) and the history of notifications shown by clicking the Notifications icon. Is there any way to control those independently? For instance, I appreciate the popups created by Macrium Reflect saying a backup has started/finished, but I don't need a history of those. On the other hand, when I was trying to get task scheduler to run a script when the the computer was going to sleep. In this case a popup would be meaningless but a record of the notification would provide diagnostic information. (And in this case either the script or the notification failed; there was nothing in the notification history list.)

Is there a way a way to control these two aspects of notifications? All I can find in the Settings is a yes/no setting for individual notifications.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Microsoft
    CPU
    Intel Core i5-8400
    Motherboard
    ASUS PRIME H370-PLUS
    Memory
    16GB
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    On board
    Monitor(s) Displays
    Samsung SyncMaster 2043BWX
    Screen Resolution
    1680 x 1050
    Hard Drives
    Samsung SSD 850 256GB
    WDC 1TB NVMe
    WD 3TB external USB drive
    PSU
    I don't remember
    Case
    Corsair something-or-other
    Cooling
    Air CPU + 2 case fans
    Keyboard
    DAS S Pro (Cherry Brown)
    Mouse
    Logitech USB of some sort
Go to Settings > System > Notifications and scroll down to the program you want to control. Click on the program name to expand the actions panel where you can set many different aspects of notifications for that program.

You can control Banners (not Toasts) and notifications in the Notification Center (when you click on the Taskbar Bell icon).

1703736295385.png
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Ryzen 9 3900X
    Motherboard
    ASUS ROG Strix X570-E Gaming
    Memory
    G-Skill RipjawsV F4-3600C18 (16GB x 2)
    Graphics Card(s)
    Gigabyte RX 5700 XT Gaming OC
    Sound Card
    Realtek ALC1220P
    Monitor(s) Displays
    ASUS VE278 (x 2)
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 850 Pro 256GB
    Samsung 970 Pro NVMe 512GB (x 2)
    ST10000VN0004 10TB (x 2)
    ST10000VN0008 10TB (x 2)
    ST4000VN000 4TB (x 2)
    PSU
    Corsair HX1000
    Case
    Corsair Carbide 400R
    Cooling
    AMD Wraith Prism (Stock)
    Keyboard
    Logitech G213
    Mouse
    Logitech G502
    Internet Speed
    100Mbps down / 40Mbps up
    Browser
    Firefox - Chrome - Edge
    Antivirus
    Windows Defender - Clamwin
Go to Settings > System > Notifications and scroll down to the program you want to control. Click on the program name to expand the actions panel where you can set many different aspects of notifications for that program.

You can control Banners (not Toasts) and notifications in the Notification Center (when you click on the Taskbar Bell icon).

View attachment 82503
Thank you. I missed that. That worked fine for the notifications from my backup programs. However, I don't see how to easily apply it to script-issued notifications. This perhaps due to my ignorance of Powershell. I stole the following PS script from somewhere a long time ago:
Powershell:
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon

$objNotifyIcon.Icon = "C:\Batch_Files\Info.ico"
$objNotifyIcon.BalloonTipIcon = "Info"
$objNotifyIcon.BalloonTipText = "Test Notification issued."
$objNotifyIcon.BalloonTipTitle = "Test"

$objNotifyIcon.Visible = $True
$objNotifyIcon.ShowBalloonTip(1000)

When I run it Settings>System>Notifications "Notifications from apps and other senders" list, sorted by most recent, shows "Windows Power Shell" at the top. Accurate but not very specific if I have more than one script issuing notification. Is there a way to attach a name or identifier to the script (or notification) so that the Settings can be applied to a specific script (or notification) rather than to all notifications issued by Powershell scripts?
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Microsoft
    CPU
    Intel Core i5-8400
    Motherboard
    ASUS PRIME H370-PLUS
    Memory
    16GB
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    On board
    Monitor(s) Displays
    Samsung SyncMaster 2043BWX
    Screen Resolution
    1680 x 1050
    Hard Drives
    Samsung SSD 850 256GB
    WDC 1TB NVMe
    WD 3TB external USB drive
    PSU
    I don't remember
    Case
    Corsair something-or-other
    Cooling
    Air CPU + 2 case fans
    Keyboard
    DAS S Pro (Cherry Brown)
    Mouse
    Logitech USB of some sort
I am no expert when it comes to Power Shell, I can usually fumble my way around, but that's all.

A quick Google revealed this, which may be of some use:
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Ryzen 9 3900X
    Motherboard
    ASUS ROG Strix X570-E Gaming
    Memory
    G-Skill RipjawsV F4-3600C18 (16GB x 2)
    Graphics Card(s)
    Gigabyte RX 5700 XT Gaming OC
    Sound Card
    Realtek ALC1220P
    Monitor(s) Displays
    ASUS VE278 (x 2)
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 850 Pro 256GB
    Samsung 970 Pro NVMe 512GB (x 2)
    ST10000VN0004 10TB (x 2)
    ST10000VN0008 10TB (x 2)
    ST4000VN000 4TB (x 2)
    PSU
    Corsair HX1000
    Case
    Corsair Carbide 400R
    Cooling
    AMD Wraith Prism (Stock)
    Keyboard
    Logitech G213
    Mouse
    Logitech G502
    Internet Speed
    100Mbps down / 40Mbps up
    Browser
    Firefox - Chrome - Edge
    Antivirus
    Windows Defender - Clamwin
I usually can't even fumble my way around in PowerShell, but I have a strong feeling that discussion you linked to isn't about the whatever-it-is that indexes the "Notifications from apps and other senders". I guess I want to know what identifies an app or other sender. (Later I'll try to figure how to set it in a script.)
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Microsoft
    CPU
    Intel Core i5-8400
    Motherboard
    ASUS PRIME H370-PLUS
    Memory
    16GB
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    On board
    Monitor(s) Displays
    Samsung SyncMaster 2043BWX
    Screen Resolution
    1680 x 1050
    Hard Drives
    Samsung SSD 850 256GB
    WDC 1TB NVMe
    WD 3TB external USB drive
    PSU
    I don't remember
    Case
    Corsair something-or-other
    Cooling
    Air CPU + 2 case fans
    Keyboard
    DAS S Pro (Cherry Brown)
    Mouse
    Logitech USB of some sort
Is there a way to attach a name or identifier to the script
I answered your question pertaining to adding an identifier or name to a script, that is why I provided that link, it is talking about exactly that.

You know exactly what you want to do, so keep that in mind while you search for an answer.
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Ryzen 9 3900X
    Motherboard
    ASUS ROG Strix X570-E Gaming
    Memory
    G-Skill RipjawsV F4-3600C18 (16GB x 2)
    Graphics Card(s)
    Gigabyte RX 5700 XT Gaming OC
    Sound Card
    Realtek ALC1220P
    Monitor(s) Displays
    ASUS VE278 (x 2)
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 850 Pro 256GB
    Samsung 970 Pro NVMe 512GB (x 2)
    ST10000VN0004 10TB (x 2)
    ST10000VN0008 10TB (x 2)
    ST4000VN000 4TB (x 2)
    PSU
    Corsair HX1000
    Case
    Corsair Carbide 400R
    Cooling
    AMD Wraith Prism (Stock)
    Keyboard
    Logitech G213
    Mouse
    Logitech G502
    Internet Speed
    100Mbps down / 40Mbps up
    Browser
    Firefox - Chrome - Edge
    Antivirus
    Windows Defender - Clamwin
I answered your question pertaining to adding an identifier or name to a script, that is why I provided that link, it is talking about exactly that.

You know exactly what you want to do, so keep that in mind while you search for an answer.
I guess I didn't clarify what kind of identifier I wanted, but I did say "so that the Settings can be applied to a specific script (or notification)"

I don't know exactly what I want to do because I have no idea what Windows uses to tie a specific notification to one of the notification Settings. Whatever that entity is, it is apparently ephemeral for PowerShell scripts. The notification setting for "Windows Power Shell" that I saw earlier has evaporated. On the other hand, notification settings for "Macrium Reflect", "Dropbox", "VeraCrypt", "File Explorer", etc., are permanent
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Microsoft
    CPU
    Intel Core i5-8400
    Motherboard
    ASUS PRIME H370-PLUS
    Memory
    16GB
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    On board
    Monitor(s) Displays
    Samsung SyncMaster 2043BWX
    Screen Resolution
    1680 x 1050
    Hard Drives
    Samsung SSD 850 256GB
    WDC 1TB NVMe
    WD 3TB external USB drive
    PSU
    I don't remember
    Case
    Corsair something-or-other
    Cooling
    Air CPU + 2 case fans
    Keyboard
    DAS S Pro (Cherry Brown)
    Mouse
    Logitech USB of some sort

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Ryzen 9 3900X
    Motherboard
    ASUS ROG Strix X570-E Gaming
    Memory
    G-Skill RipjawsV F4-3600C18 (16GB x 2)
    Graphics Card(s)
    Gigabyte RX 5700 XT Gaming OC
    Sound Card
    Realtek ALC1220P
    Monitor(s) Displays
    ASUS VE278 (x 2)
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 850 Pro 256GB
    Samsung 970 Pro NVMe 512GB (x 2)
    ST10000VN0004 10TB (x 2)
    ST10000VN0008 10TB (x 2)
    ST4000VN000 4TB (x 2)
    PSU
    Corsair HX1000
    Case
    Corsair Carbide 400R
    Cooling
    AMD Wraith Prism (Stock)
    Keyboard
    Logitech G213
    Mouse
    Logitech G502
    Internet Speed
    100Mbps down / 40Mbps up
    Browser
    Firefox - Chrome - Edge
    Antivirus
    Windows Defender - Clamwin

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Microsoft
    CPU
    Intel Core i5-8400
    Motherboard
    ASUS PRIME H370-PLUS
    Memory
    16GB
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    On board
    Monitor(s) Displays
    Samsung SyncMaster 2043BWX
    Screen Resolution
    1680 x 1050
    Hard Drives
    Samsung SSD 850 256GB
    WDC 1TB NVMe
    WD 3TB external USB drive
    PSU
    I don't remember
    Case
    Corsair something-or-other
    Cooling
    Air CPU + 2 case fans
    Keyboard
    DAS S Pro (Cherry Brown)
    Mouse
    Logitech USB of some sort
Except all notifications are sourced by NotifyOnDemand, which is the same effect of running a PS script and being identified from a single source.
 

My Computer

System One

  • OS
    Windows 7
Except all notifications are sourced by NotifyOnDemand, instead of your PS example.
Well, so far that's a little better than having them all sourced by PS. (Especially since, so far, "them all" is just one script.) But having some way to set an arbitrary source would be handy.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Microsoft
    CPU
    Intel Core i5-8400
    Motherboard
    ASUS PRIME H370-PLUS
    Memory
    16GB
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    On board
    Monitor(s) Displays
    Samsung SyncMaster 2043BWX
    Screen Resolution
    1680 x 1050
    Hard Drives
    Samsung SSD 850 256GB
    WDC 1TB NVMe
    WD 3TB external USB drive
    PSU
    I don't remember
    Case
    Corsair something-or-other
    Cooling
    Air CPU + 2 case fans
    Keyboard
    DAS S Pro (Cherry Brown)
    Mouse
    Logitech USB of some sort
I just finished some research, and don't pretend to be any expert, but to self-identify your notification source -- a real or fake AppUserModelId needs to be registered.

We can't use the simple NotifyIcon() method, because it won't allow us to pass any arbitrary AppUserModelId, instead it takes the profile of the parent PowerShell or ISE process.

1. Create one or more AppUserModelId Classes, each with a random GUID:
Code:
C:\Users\GARLIN>powershell (New-Guid).Guid
63410a2a-42d7-4019-b8cb-2fc2604eeb4c

My two new Classes are "PowerShell.Script1" & "PowerShell.Script2"
Random GUID's are arbitrarily chosen, you can re-use mine or create your own.
Code:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppUserModelId\PowerShell.Script1]
@=""
"DisplayName"="PowerShell Script 1"
"CustomActivator"="{d3644ec3-0142-443b-b08b-357eb21917d4}"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppUserModelId\PowerShell.Script2]
@=""
"DisplayName"="PowerShell Script 2"
"CustomActivator"="{2a0537b1-c027-4378-9b75-7c7e481d60c0}"

2. Adapt the Toast Notification method from PowerShell can I use balloons, toasts and notifications?
Code:
    [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null

    # Toasts templates: https://msdn.microsoft.com/en-us/library/windows/apps/hh761494.aspx
    $template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)

    # Convert to .NET type for XML manipulation
    $toastXml = [xml] $template.GetXml()

    # Customize the toast message
    $toastXml.GetElementsByTagName("text")[0].AppendChild($toastXml.CreateTextNode("Script 1 test")) > $null
    $toastXml.GetElementsByTagName("text")[1].AppendChild($toastXml.CreateTextNode("Time is now " + [DateTime]::Now.ToShortTimeString() + ".")) > $null

    # Convert back to WinRT type
    $xml = New-Object Windows.Data.Xml.Dom.XmlDocument
    $xml.LoadXml($toastXml.OuterXml)

    $toast = [Windows.UI.Notifications.ToastNotification]::new($xml)

    # Unique Application id/tag and group
    $toast.Tag = "PowerShell.Script1"
    #$toast.Group = "PowerShell.Script1"

    # Create the toasts and show the toast. Make sure to include the AppId
    $notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($toast.Tag)
    $notifier.Show($toast)

    #########

    # Convert to .NET type for XML manipulation
    $toastXml = [xml] $template.GetXml()

    # Customize the toast message
    $toastXml.GetElementsByTagName("text")[0].AppendChild($toastXml.CreateTextNode("Script 2 test")) > $null
    $toastXml.GetElementsByTagName("text")[1].AppendChild($toastXml.CreateTextNode("Time is now " + [DateTime]::Now.ToShortTimeString() + ".")) > $null

    # Convert back to WinRT type
    $xml = New-Object Windows.Data.Xml.Dom.XmlDocument
    $xml.LoadXml($toastXml.OuterXml)

    $toast = [Windows.UI.Notifications.ToastNotification]::new($xml)

    # Unique Application id/tag and group
    $toast.Tag = "PowerShell.Script2"
    #$toast.Group = "PowerShell.Script2"

    # Create the toasts and show the toast. Make sure to include the AppId
    $notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($toast.Tag)
    $notifier.Show($toast)

3. When the two toasts are delivered, each is tagged by a different "App". There's no reason why you can't create more sources as you need, just as long as you can map the identifier Tag to a registered Class.

Windows 11 x64-2023-12-28-21-13-00.png

Windows 11 x64-2023-12-28-21-13-13.png
 

My Computer

System One

  • OS
    Windows 7
Thank you very much! That's exactly what I needed.

It will take me a while to digest that since I know next to nothing about Windows notification (the difference between a banner and a toast, for instance), and I have to reacquaint myself with object-oriented programming whenever confronted with an object. I could just blindly copy what you have - changing names and text strings, of course - but I'd rather understand what I'm doing.

I'll dig into this in a couple days.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Microsoft
    CPU
    Intel Core i5-8400
    Motherboard
    ASUS PRIME H370-PLUS
    Memory
    16GB
    Graphics Card(s)
    Intel UHD Graphics 630
    Sound Card
    On board
    Monitor(s) Displays
    Samsung SyncMaster 2043BWX
    Screen Resolution
    1680 x 1050
    Hard Drives
    Samsung SSD 850 256GB
    WDC 1TB NVMe
    WD 3TB external USB drive
    PSU
    I don't remember
    Case
    Corsair something-or-other
    Cooling
    Air CPU + 2 case fans
    Keyboard
    DAS S Pro (Cherry Brown)
    Mouse
    Logitech USB of some sort
The script uses one of the Windows-provided XML templates for layout. There's a few more templates available.

What's really different is you're using a different API. There's like 4-5 distinct methods to create a notification event, but since your requirement is to use an unique source identifier, that removes most of the other API paths. Frankly, most of the available resources are unintelligible unless you're an UI developer.
 

My Computer

System One

  • OS
    Windows 7
Back
Top Bottom