Wednesday, August 29, 2012

Notepad.exe command line arguments

I was looking for Notepad’s arguments for a sample I’m thinking of writing; I’ve searched the net and found some of these, and had to investigate a bit to find out about the others. I’m a bit surprised it only supports so few flags, I was expecting at least a “go to line” capability. Anyway, here they are:

/A      Ansi: notepad /a file.txt Opens the specified file as Ansi (overrides encoding auto-detection)

/W      Wide: notepad /w file.txt Opens the specified file as Unicode (overrides encoding auto-detection)

/P      Print: notepad /p file.txt Opens the file, prints its content to the default printer and exit

/PT     PrintTo: notepad /pt “file.txt” “<printername>” prints the file to the specified printer. Both the filename and the printer name have to be in quotes, regardless of the names containing spaces or not. E.g.: notepad /pt “file.txt” “Send To OneNote 2013” or notepad /pt “file.txt” “\\Server\SharedPrinter

/.SETUP SetupMode: E.g. notepad /.setup file.txt.  I’m unclear what this is used for. It’s a weird mode, it does not repaint the window if it was started restored. You’d have to press Alt-Space and Maximize it to view the file content. The window has 2 sets of scrollbars in that case (one set is apparently unused), and it closes if Escape or Ctrl+D are pressed. Perhaps some setup programs invoke notepad with these arguments to display the EULA? Who knows.


That being said, for a better small & fast replacement of notepad, I suggest using SaneStudio’s NitroLite, downloadable from No installation needed, at only ~100kb, it packs loads of features, syntax coloring, binary editor, etc.

No comments: