8

I have this powershell script to send a notification which works great, except for the fact that it is not saved in the notification center. It times out, and fades away, but it is not there when you click the notifications button on the right of the taskbar. Is there anything I could add to my script to make it happen? Thanks!

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

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

$objNotifyIcon.Icon = "icoOnline.ico"
$objNotifyIcon.BalloonTipIcon = "None" 
$objNotifyIcon.BalloonTipText = "wzzup this is a title." 
$objNotifyIcon.BalloonTipTitle = "WHATS UPPP THIS IS A PARAGRAPH!"

$objNotifyIcon.Visible = $True 
$objNotifyIcon.ShowBalloonTip(10000)
5
  • 2
    Look at using toast notifications instead of winforms, it is the newer standard. Search google, GitHub or psgallery for a module that already does it or an example like this. This module seems to be the most popular.
    – jkdba
    Commented Nov 4, 2017 at 23:47
  • thanks @jkdba I'll give that a go.
    – Mark Deven
    Commented Nov 6, 2017 at 16:53
  • That still did not show up in the action center after it appeared.
    – Mark Deven
    Commented Nov 6, 2017 at 17:04
  • My script does use toast notifications... as of Windows 10 Toast and Windforms are the same.
    – Mark Deven
    Commented Nov 6, 2017 at 17:05
  • In my case it did persistant in action center, only disappeared after I hover my cursor over the notification icon in taskbar.
    – ttimasdf
    Commented Apr 8, 2020 at 2:33

1 Answer 1

10

You can use a while condition to make it last. But again dont make the script hold permanently. Instead you can create a background job for the same.

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon
while($True)
{
$objNotifyIcon.Icon = [System.Drawing.SystemIcons]::Information
$objNotifyIcon.BalloonTipIcon = "Info" 
$objNotifyIcon.BalloonTipTitle = "wzzup this is a title." 
$objNotifyIcon.BalloonTipText = "WHATS UPPP THIS IS A PARAGRAPH!"
$objNotifyIcon.Visible = $True 
$objNotifyIcon.ShowBalloonTip(10000)
Start-Sleep 500
}

Hope it helps.

1
  • In my case it did persistant, only disappeared after I hover my cursor over the notification icon in taskbar.
    – ttimasdf
    Commented Apr 8, 2020 at 2:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.