On Windows 11 how to generate with `cmd` or PowerShell a notification?
Jun 24, 4:11pm

On Windows 11, you can generate a system notification (toast) using PowerShell or Command Prompt (cmd). Here’s how to do it in both:


1. Using PowerShell

You can use the New-BurntToastNotification cmdlet from the BurntToast module (requires installation) or use a native approach with Windows.UI.Notifications.

Native PowerShell (No Module Required)

powershell
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$notify = New-Object System.Windows.Forms.NotifyIcon
$notify.Icon = [System.Drawing.SystemIcons]::Information
$notify.BalloonTipTitle = "Notification Title"
$notify.BalloonTipText = "This is your notification message!"
$notify.BalloonTipIcon = "Info"
$notify.Visible = $true
$notify.ShowBalloonTip(5000) # Shows for 5 seconds
Start-Sleep -Seconds 5
$notify.Dispose()
  • This creates a system tray notification (not a toast).

Using BurntToast Module (Recommended for Toast Notifications)

  1. Install the module:
    powershell
    Install-Module -Name BurntToast -Force
  2. Create a toast notification:
    powershell
    Import-Module BurntToast
    New-BurntToastNotification -Text "Hello, Benjamin!", "This is a toast notification from PowerShell."

2. Using Command Prompt (cmd)

You can use VBScript or PowerShell from cmd to generate a notification.

Using VBScript (Simple Popup)

cmd
echo Set objWSHShell = WScript.CreateObject("WScript.Shell") > temp.vbs
echo objWSHShell.Popup "This is a popup notification!", 5, "Notification Title", 64 >> temp.vbs
start temp.vbs
  • This creates a popup dialog (not a toast).

Using PowerShell from cmd

cmd
powershell -command "Add-Type -AssemblyName System.Windows.Forms; $notify = New-Object System.Windows.Forms.NotifyIcon; $notify.Icon = [System.Drawing.SystemIcons]::Information; $notify.BalloonTipTitle = 'Notification'; $notify.BalloonTipText = 'Hello from CMD!'; $notify.BalloonTipIcon = 'Info'; $notify.Visible = $true; $notify.ShowBalloonTip(5000); Start-Sleep -Seconds 5; $notify.Dispose()"
  • This is the same as the PowerShell method above but executed from cmd.

3. Native Toast Notification (Windows 10/11)

For true toast notifications, use the following PowerShell script (requires Windows 10/11):

powershell
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null

$template = @"
<toast>
    <visual>
        <binding template="ToastText02">
            <text id="1">Notification Title</text>
            <text id="2">This is a native toast notification!</text>
        </binding>
    </visual>
</toast>
"@

$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Windows PowerShell").Show($toast)
  • This creates a native Windows toast notification.

Which to Use?

  • For toast notifications, use the BurntToast module or the native PowerShell method.
  • For simple popups, use VBScript or the NotifyIcon method.
Jun 24, 4:11pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more