I have a script that is associated with a keyboard shortcut, when I trigger the shortcut, I want a notification to appear confirming that the script executed.

How do I create a notification from inside a script?


On Linux, I used to do command && notify-send "My message"

  • echo msgbox "the message that you want" > "%temp%\popup.vbs" wscript.exe "%temp%\popup.vbs"
    – Aardwolf
    Mar 17, 2020 at 22:24

1 Answer 1


In PowerShell you can run (from here):

$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.visible = $true
$notify.showballoontip(10,"Script Completed!","Your script ran succesfully!",[system.windows.forms.tooltipicon]::None)

Or this (from here):

$ErrorActionPreference = "Stop"
$notificationTitle = "Notification: Your script has been completed successfully"
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01)
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($notificationTitle)) > $null
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
$toast.Tag = "Test1"
$toast.Group = "Test2"
$toast.ExpirationTime = [DateTimeOffset]::Now.AddSeconds(5)
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Script Completed!")
  • Is there a way to auto clear it after a few seconds?
    – olfek
    Mar 17, 2020 at 22:39
  • Also, I don't want an icon to show in the taskbar, notification only.
    – olfek
    Mar 17, 2020 at 22:47
  • @daka, added 2nd method that has does show in the taskbar and has an expireing-seconds parts Mar 18, 2020 at 0:36
  • Regarding the second way, removing Notification: from $notificationTitle makes it stop working, why?
    – olfek
    Mar 18, 2020 at 10:57
  • @daka works for me (see i.imgur.com/AzjMFwu.png). Did you make sure to leave the opening quotes before it? Mar 18, 2020 at 12:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .