How to show a message box on Windows 10

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

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

Need to show a toast notification? Use a PowerShell module.

Custom message box on Windows 10

A custom message box will have a title, a message, and a call to action button i.e., an OK button which will dismiss the message. 

how to show a message box on windows 10 How to show a message box on Windows 10

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

1. Batch/PowerShell script to show message box

Follow the steps below to create the script.

  1. Open a new Notepad file (or use any text editor of your choice).
  2. Paste 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 intend to use a PowerShell script, remove the first line: @echo off.
  2. Edit the script as below:
    • Replace ‘My Message‘ with the message you want the message box to show.
    • Replace “Message Title” with the title of the message box you want.

Example:

@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 a batch script or the .ps1 extension for a PowerShell script.
  2. Run the script and the message box will appear.

how to show a message box on windows 10 1 How to show a message box on Windows 10

2. Command Prompt or PowerShell – Message box

Showing a message box from the Command Prompt or from PowerShell is easy. You do not need admin rights to show the message box.

Command Prompt

  1. Open Command Prompt.
  2. Run the following command in it.
  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 show.
    • Replace “Message Title” with the title you want the message box to have.
@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);}"

how to show a message box on windows 10 2 How to show a message box on Windows 10

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 message you want the message box to show.
    • Replace “Message Title” with the title you want the message box to have.
powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('My Message', 'Message Title', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"

how to show a message box on windows 10 3 How to show a message box on Windows 10

Check Also

dns server not responding how to fix dns not responding on windows 10 DNS Server Not Responding: How to Fix DNS Not Responding on Windows 10

DNS Server Not Responding: How to Fix DNS Not Responding on Windows 10

Every device that connects to the internet, sends a request to a DNS server that …

Leave a Reply