Skip to main content

How to Open MS Paint in a Batch Script

Microsoft Paint is a simple but surprisingly useful graphics editor that has been included with all versions of Windows. From a batch script, you might want to open MS Paint to allow a user to quickly view or edit an image, to paste and save a screenshot, or as part of a simple utilities menu.

This guide will teach you the basic command to launch mspaint.exe. More importantly, you will learn the critical difference between launching it as a blocking process and launching it in the background using the START command, which is the recommended method for most scripts.

The Core Command: mspaint.exe

The executable file for Microsoft Paint is mspaint.exe. Because this program is located in the System32 directory, which is part of the system's default PATH environment variable, you do not need to provide the full path. You can simply use its name.

Syntax: mspaint

Basic Example: Launching MS Paint

This is the most direct way to run the program. However, it has a significant side effect: it is a blocking command.

For example:

@ECHO OFF
ECHO --- Launching MS Paint ---
ECHO.
ECHO The script will now pause and wait for you to close the Paint window.

mspaint

ECHO.
ECHO --- MS Paint was closed ---
ECHO The script has now resumed.
PAUSE

When you run this script, it will open MS Paint and then halt execution. The "MS Paint was closed" message will not appear until you have completely closed the Paint application window.

The Better Method: Using the START Command

For most use cases, you want your batch script to launch Paint and then continue with its own execution, or simply exit. This is an asynchronous or "background" launch. The command for this is START.

Syntax: START "" mspaint

  • START: The command to launch a new process.
  • "": A required dummy "title". The START command's first quoted string is always treated as the title for a new window. To run a command, you must provide a title first, even if it's just empty quotes.
  • mspaint: The program to run.

For example:

@ECHO OFF
ECHO --- Launching MS Paint in the Background ---
ECHO.

START "" mspaint

ECHO The main script is continuing immediately without waiting for Paint to close.
ECHO.
PAUSE

When this script runs, MS Paint will open, and the batch script will immediately continue to the next line without pausing. This is the recommended method for most scripts.

Opening a Specific Image File with MS Paint

To open an existing image file directly in Paint, you simply provide the path to the file as a command-line argument.

This script uses the robust START command to open a specific image file.

@ECHO OFF
SET "ImageFile=C:\MyPhotos\vacation.png"

IF NOT EXIST "%ImageFile%" (
ECHO [ERROR] Image file not found: "%ImageFile%"
PAUSE
GOTO :EOF
)

ECHO Opening "%ImageFile%" in MS Paint...
START "" mspaint "%ImageFile%"
note

As always, it is a best practice to quote the file path to handle any spaces.

Common Pitfalls and How to Solve Them

  • Script Pauses Unexpectedly: This is the most common issue, caused by running mspaint directly instead of using START.

    • Solution: Unless you explicitly want your script to halt, always use START "" mspaint.
  • mspaint Command Not Found: This is extremely rare, as mspaint.exe is a core Windows component and its location (%SystemRoot%\System32) is in the system PATH. If you are working in a highly restricted or broken environment, the command could fail.

    • Solution: You can use the full, robust path to the executable: START "" "%SystemRoot%\System32\mspaint.exe".
  • Forgetting the START Title: A common mistake is to run START "C:\Path\to\image.png". This will not open the image. It will open a new, empty command prompt window with that path as its title.

    • Solution: Remember the START command's quirky syntax. The title comes first: START "My Image" mspaint "C:\Path\to\image.png". Using empty quotes ("") for the title is the simplest and most common practice.

Practical Example: A Simple "Screenshot Helper" Script

This script provides a user-friendly way to take and save a screenshot. It instructs the user, waits for them, and then opens a blank Paint canvas for them to paste and save their image.

@ECHO OFF
TITLE Screenshot Helper
CLS

ECHO --- Screenshot Helper ---
ECHO.
ECHO This utility will help you capture and save a screenshot.
ECHO.
ECHO 1. Prepare your screen to capture the image you want.
ECHO 2. Press the 'Print Screen' (PrtScn) key on your keyboard.
ECHO (This copies the entire screen to your clipboard).
ECHO 3. Return to this window and press any key.
ECHO.
PAUSE

ECHO.
ECHO Opening MS Paint now...
ECHO Once Paint is open, press Ctrl+V to paste your screenshot.
TIMEOUT /T 3 > NUL

REM --- Launch Paint in the background so this script can exit ---
START "" mspaint

ECHO The batch script has finished. You can now work in MS Paint.

Conclusion

Launching MS Paint from a batch script is a simple and useful task for interacting with the user or with image files.

Key takeaways:

  • The executable is mspaint.exe.
  • Running mspaint by itself is a blocking command that will pause your script.
  • The recommended method is to use START "" mspaint, which launches Paint asynchronously and allows your script to continue.
  • To open a specific file, provide the file path as an argument: START "" mspaint "path\to\image.jpg".