How to show a message box on Windows 10

Apps can display alerts when they need a user’s attention e.g., the warning ‘Do you want to save changes’ you will try to close a Notepad file with unsaved changes. They can also show messages eg when a file is downloaded or processed.

These messages are useful but do not have to come from an app. Users can display a custom message box on Windows 10 using a batch script, a PowerShell script, or by running a command in Command Prompt or PowerShell.

Need to display a toast message? Use the PowerShell module.

Custom message box on Windows 10

A custom message box will contain a title, a message, and a call to action button ie, an OK button that deletes the message.

First, decide if you want to use a script or run a command. Running a command is easier so let’s go over the script method first.

1. Batch Script / PowerShell to display a message box

Follow the steps below to create the script.

  1. Open a new one Notepad file (or use any text editor of your choice).
  2. Enter the following in the Notepad file.
@echo off

powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('My Message', 'Message title', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"
  1. If you plan to do that use PowerShell script, delete first line: @echo off.
  2. Edit the script as below:
    • Replace ‘My message‘with the message you want the message box to display.
    • Replace “Message title” with the the title of the message box you want.

Examples:

@echo off

powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('Go to the reactor room', 'Reactor Meltdown', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"
  1. Save the file with the .bat extension for batch script no an.ps1 extension for PowerShell script.
  2. Run the script and the message a box will appear.

2. Command Prompt or PowerShell – Message box

A message box can be easily displayed from Command Prompt or PowerShell. You do not need administrative rights to display the message box.

Prompt Command

  1. Open Prompt Command.
  2. Run the following a command innte.
  3. Edit the command as below to set your custom message and title.
    • Replace ‘My message’ with the message you want the message box to display.
    • Replace “Message message” with the title you want have the message box.
@echo off

powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('My Message', 'Message Title', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"

PowerShell

  1. Open PowerShell.
  2. Run the following command.
  3. Edit the command to add your own message and title.
    • Replace ‘My message’ with the missed messaget the message box to display.
    • Replace “Message message” with the title you want have the message box.
powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('My Message', 'Message Title', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"

The post Show how to display a message box on Windows 10 first on TechtricksNg.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top