Create a windows protocol

  notifications, powershell, windows

I work on that case since lot of days and lot of hours without understanding where I make a mistake.
The context of my problem is the following one:
I use the Notification from the imab website and I wanted to modify the “Dismiss” button so when the user click on it, it will increase a value and while the max value is reach, then it will force the upgrade of the computers.
To do so, I copied the same process of the “Install now” (or “restart”, as I wanted to use it for both cases) button.
I create this reg file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOTToastDismissReboot]
@="URL:ToastRebootDismiss Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOTToastDismissRebootshell]

[HKEY_CLASSES_ROOTToastDismissRebootshellopen]

[HKEY_CLASSES_ROOTToastDismissRebootshellopencommand]
@="C:ProgramDataToastNotificationScriptToastRunDismissReboot.cmd"

I place my ToastRunDismissReboot.cmd script in the following location: “C:ProgramDataToastNotificationScript”

On the Notification scripts file, I have this two lines to get the action of the buttons reboot now and dismiss, on the xml configuration file :

<Option Name="Action" Value="ToastReboot:" />
<Option Name="Dismiss" Value="ToastRebootDismiss:" />

And these on the ToastNotification.ps1 file:

$Action = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action'} | Select-Object -ExpandProperty 'Value'
$Dismiss = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Dismiss'} | Select-Object -ExpandProperty 'Value'

The notification looks like that:

enter image description here

And while I click on dismiss I get that error:

enter image description here

The “restart now” button works properly, but the dismiss one doesn’t. I’m completely stuck.
Can someone help me?

Thank you,
Noémie.

Source: StackOverflow

One Reply to “Create a windows protocol”

  • Hey, the entire New-ToastNotification.ps1 script does not support having actions tied to the dismiss button. It’s possible to have that, but that will require that you make additional modifications to the script. Reach out on my mail if you need help 🙂

LEAVE A COMMENT