How to send notifications to the Action Center?

匿名 (未验证) 提交于 2019-12-03 08:44:33

问题:

I have only found this, which seems not to be related to the Action Center.

I guess there is a simple way to send a notification with PowerShell, but I seem incapable to find it.

回答1:

The notifications that show up in the action center tend to be Toast Notifications that the user didn't click away while they were on screen.

e.g. I insert a blank dvd, get a toast asking what I want to do with it but don't click it, it then shows up in the list of notifications in the Action Center.

I'm not sure of a way to bypass the toast step.

So what you probably want to have are Toasts (maybe silent?) which will wind up in the action center.

I wrote a powershell module for displaying these Toasts, BurntToast (or check out the GitHub repo for instructions and examples, etc.)

Feel free to use the module as is, or rip it apart to figure out how it works and do your own implementation. There are plenty of examples and documentation of how to do this in C# and/or modern applications too, now that you know the keyword to search for.



回答2:

How about some toast with your job?

Get-EventSubscriber -SourceIdentifier JobEnd -EA 0| Unregister-Event $action = { if ($sender.State -eq 'Completed') {     Write-Host $sender.Name -fore green     Import-Module d:\scripts\BurntToast     $global:jobInfo = Receive-Job $job     New-BurntToastNotification -Text 'Job Completed'. "Job:  $($sender.Name) was successful" } } $job = Start-Job { Start-Sleep -Seconds 5; 1 .. 5 } Register-ObjectEvent $job -EventName StateChanged -SourceIdentifier JobEnd  -Action $action $job.State


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!