I'm using this code to send notifications from PowerShell script. PowerShell itself is launched by (persistent) Java application.
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$template = "<toast><visual><binding template=`"ToastText02`"><text id=`"1`">Title</text><text id=`"2`">Test results</text></binding></visual></toast>"
$xml.LoadXml($template)
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("sbt").Show($toast)
They pop up on the screen and are visible in Action Center for while but quickly disappear. Notifications sent by the XAML app with the same code stay there for quite some time. Is there a way to change behavior of notifications sent via script?
You must set a registry key for each AppID
whose notifications you would like to persist in the Action Center.
For example, if you want your irssi
notifications to persist, add the key: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\irssi
with a DWORD named ShowInActionCenter
with value 1
.
Thanks to "Passing By" for the solution in this article's comments, and Mattias Fors for creating the article.
Update: You can also toggle this in your "Notifications & actions" Settings on a per-app basis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With