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.

Loading Notepad from command prompt
An administrative command prompt also works, but isn't required.
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.

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.

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".

Printing from command prompt
Notepad automatically closes after printing.
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".