How to Use Notepad.exe from Command Prompt

Open Notepad With the Command Prompt

Usually, running a program from the command prompt requires you to navigate to the application's directory first. Windows system programs including Notepad, however, work from any directory. Open the command prompt -- press Windows-R and run Cmd, or in Windows 8, press Windows-X and select Command Prompt -- and type Notepad to run the program. On its own, this command opens Notepad in the same way as if you had loaded it through the Start menu or Start screen.

An administrative command prompt also works, but isn't required.
Image Credit: Image courtesy of Microsoft

To load a text file from the prompt, enter its name -- including directory and extension -- in quotes, such as Notepad "C:\Documents\File.txt". You have to include the full directory of the file unless the file is in the prompt's current directory. If it is, simply use the file's name and extension in quotes: Notepad "File.txt". Optionally, you can omit the quotes if your file name has no spaces.


  • To open the command prompt to a specific directory, open the directory in File Explorer, hold Shift, right-click an empty space in the window, and then choose Open Command Window Here.
  • Command prompt commands are case insensitive -- Notepad works the same as notepad.

Command Line Arguments

In addition to loading a file, Notepad has a few command line arguments for changing the program's encoding system and printing.

Encoding Options

By default, Notepad automatically detects the type of encoding used in a text file when loading it. To override the automatic detection, enter either /a for ANSI or /w for Unicode (UTF-16) prior to the file's name. For example, Notepad /a "C:\Documents\File.txt" opens File.txt with ANSI encoding, regardless of the encoding used when saving the file.


  • Loading a file using the wrong encoding system causes it to appear unreadable, but won't damage the file as long as you don't make changes and save it. Usually, you're better off not specifying an encoding setting and letting Notepad figure it out automatically.
  • UTF-8-encoded files won't display correctly with either the /a or /w switch, only when loaded without either.

Printing Options

Print a text file directly from the command prompt using the default printer by inserting /p prior to the file's name: Notepad /p "C:\Documents\File.txt".

Notepad automatically closes after printing.
Image Credit: Image courtesy of Microsoft

To use an alternative printer, change /p to /pt and enter the printer's full name in quotes after the file name. For example, Notepad /pt "C:\Documents\File.txt" "InkJet Printer 1500" prints File.txt to a printer named Inkjet Printer 1500. For a network printer, give its location on the network, such as "\HOSTPC\PrinterName".


Check the list of installed printers in the Devices and Printers Control Panel to find a printer's name. Open the panel directly from the command prompt by running Control Printers.