130

I can start the regular Notepad from cmd.

C:\Windows>notepad

I can also start it from the run prompt.

  1. Win+R
  2. notepad
  3. Enter

I want to be able to do the same with the Notepad++. I can start it from the run prompt, but I can't start it from cmd.

I can also open a specific file in Notepad from cmd.

C:\Windows>notepad d:\mytext.txt

I want to be able to do the same with Notepad++.

Is this possible, and what can I do to enable this?

Stevoisiak
  • 16,075
Samir
  • 21,235

11 Answers11

205

Even though the Notepad++ directory is not in your path, you can use the command below to run the program from the command prompt:

start notepad++

To open a file in Notepad++, run:

start notepad++ <filename>
aschultz
  • 157
sudha jallu
  • 2,051
85

You could add C:\Program Files (x86)\Notepad++ to your PATH environment variable.

For example, you could run the following on the command prompt:

set PATH=%PATH%;C:\Program Files (x86)\Notepad++

For further options, see What are PATH and other environment variables, and how can I set or use them?

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
21

I would not want to clutter my PATH just for using a single tool.

One alternative is to use an alternative text editor as 100% replacement for Notepad as explained here with many details. Another description with a dedicated editor launcher tool can be found here. Another Notepad++ launcher on github.

A less invasive alternative is a cmd file like this:

"C:\Programme\Notepad++\notepad++.exe" %*

This file has to reside somewhere along the existing PATH. I actually put all my tools in one common UTIL directory, which is part of PATH.

Axel Kemper
  • 4,038
14

This is what I have done, in this way you dont have to type notepad++ Create np.bat file with this set of commands

@echo off
start "" "C:\Program Files (x86)\Notepad++\notepad++.exe" %*

place np.bat file in c:\Windows

open the command prompt and type np or np myfile.txt and enter.

7

Combining the answers from Axel Kemper and adding some extra's, here is what I did to make a permanent command that you can give any name you want.

First of all I created an extra folder. In my case: "C:\Users\Hansel\CmdFiles". In this folder I created a new text file throught the right click menu -> new -> text document. Edit the text document using notepad or notepad++ and type the following code in the .txt file:

@echo off
"C:\Software\Notepad++\notepad++.exe" %*

Then you have to rename the file to your personal command, for example "npp.cmd".

On a side note: the @echo off prevents the command from printing to the command prompt;

the link between the quotation marks can refer to any executable;

*%** will make sure that anything you type after the npp command (for example "npp nonsense.txt") will be put after the original command in the quotation marks.

Then you need to edit an "environment variable", in this case the so called PATH (this variable contains the folders where Windows looks for commands and executables). To add the folder to your PATH, push the windows button to enter the start menu and type "edit environment variables for your account". Under "User variables for Hansel", create a new "Path" variable if it does not exist or edit the old "Path" variable if there is one.

If you make a new PATH variable, the variable value should just read: C:\Users\Hans\CmdFiles

If you edit an old PATH variable, the variable value should read: oldstuff;C:\Users\Hans\CmdFiles (mind the semi colon).

Windows now looks for commands in the folder "C:\Users\Hansel\CmdFiles" and you can easily add new commands to this folder!

Hansel
  • 104
3

A simple way to run any program installed on Windows from command is:

  1. Find the location of notepad++.exe, create a shortcut under the installation directory.

  2. cut and paste the shortcut to C:/windows/system 32.

  3. Now you can press 'Win + R' and type the name of shortcut. All done.

PS: in my case, I named the shortcut 'notepadpp' (or even 'nppp') so that I don't have to press 'shift + =' twice for '+' symbol

Extremely simple and easy, and it's easy to delete the shortcut. You don't even need to change the path, registry

2

To run any program from command line with a short name you can create an alias for it by the command doskey:

doskey alias="drive:\path to program\executable" $*

For example, after running command
doskey notepad++="C:\Program Files (x86)\Notepad++\notepad++.exe" $*
you can open the text file with notepad++ by notepad++ textfile. Of course, you can use shorter alias something as npp or n++.

Also you can create alias for some path you often open:

doskey home=cd C:\Users\myprofile

But unfortunately you cannot use this alias in path. If you run doskey home=C:\Users\myprofile and then enter in the command line cd home or start home\myfile you receive error message.

To create your aliases automatically each time when cmd runs you can put its into the batch file like autorun.cmd and set it in the registry entry:

HKCU\Software\Microsoft\Command Processor\AutoRun

or

HKLM\Software\Microsoft\Command Processor\AutoRun

Links to the articles:
Console Aliases
Command Processor\AutoRun

2

Add the program directory to your PATH.

Oesor
  • 310
2

One way is to make a change to this registry key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Notepad++.exe]

You can download a zipped .reg file from Donn Felker that lets you open a file with just an n shortcut.

I edited the .reg before running it and to make sure the path to Notepad++ is correct (e.g. C:\Program Files (x86)) and I also changed the shortcut to n instead of n.

Then double click to add to your registry.

Hugo
  • 3,010
0

In PowerShell:

$ENV:Path="$ENV:Path;C:\Program Files (x86)\Notepad++"
0

Notepad++ has quite a cult following. And those people who like what Notepad++ can do will likely be frequent users of this program. So it only makes sense for these people to want easy access to Notepad++ ... and put Notepad++ on the system Path.

And these are likely the same people who would want a script to start notepad++ with a keyboard shortcut:

^q::run "Notepad++.exe"
Gray
  • 187