Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep powershell notification in action center

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)
like image 841
Mark Deven Avatar asked Nov 04 '17 21:11

Mark Deven


1 Answers

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.

like image 159
Ranadip Dutta Avatar answered Oct 11 '22 06:10

Ranadip Dutta