Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
In Windows Vista, Windows 7, 8you can you can use start menu search box like run command. No need to press Win+R. Press Win and type in search box. Try it! –  Kamil Aug 26 at 0:25

5 Answers 5

up vote 7 down vote accepted

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?

share|improve this answer
    
Thanks! It works now. Now I can do notepad++ %userprofile%\desktop\testfile.txt which is nice. I used the Environment Variables dialog box for this. What's the syntax for removing an environment variable using the set command? I couldn't find any specific switches or syntax for this. Not on the link you provided and not on the Computer Hope website. –  sammyg Jun 13 '13 at 21:24
1  
@Sammy: Removing a single directory from the PATH variable is best done through the GUI, I assume. I don't know how to quickly remove it from the command line. If you want to completely remove an environment variable, you can use set something=, but I wouldn't advise you to do that for PATH. –  Oliver Salzburg Jun 13 '13 at 21:26
    
I found a path command. I understand I'm supposed to use semi colon to delete a path in the PATH variable?... I'm not sure how. –  sammyg Jun 13 '13 at 21:32
    
Using path ; clears the search path settings for the current instance of cmd. It doesn't actually remove the search paths from the PATH variable. By opening a new cmd window the search path settings are restored. Oh well, I guess I will use the GUI then. –  sammyg Jun 13 '13 at 21:47
1  
This is worth noting: "Changes made with SET will remain only for the duration of the current CMD session." This can be found here. And it says that Set command is used to display, set, or remove CMD environment variables. So Set command can be used to remove the whole variable, in this example the PATH variable. And again, it will not be permanently removed from Windows. It is only valid for the duration of the CMD session. To permanently set an environment variable from CMD, the Setx command should be used instead. Either that or GUI. –  sammyg Jun 13 '13 at 22:09

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

One alternative is to use Notepad++ as 100% replacement for Notepad as explained here.

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.

share|improve this answer
    
What do you mean by "cmd file"? And what's with the asterisk and the percent sign? What file has to reside "along" the PATH? (It's not like it's going somewhere.) How do you make use of UTIL? Last time I checked there is no variable called UTIL. Is this something you came up yourself and added manually to the system? Can you explain any of this? And maybe give me some concrete example I can work with and hopefully learn from? Or are you just here to brag about how you know command line? I don't mean to be rude or anything, I'm just saying how it is. We all have different skill levels. –  sammyg Jun 14 '13 at 15:33
1  
A cmd file could be the text script file npp.cmd which has the command as single text line inside. If you create a directory c:\util and put the script file into it, extend your PATH by c:\util, you from then on can call Notepad++ by typing "npp". %* stands for "all commandline arguments". –  Axel Kemper Jun 14 '13 at 17:41
    
A cmd file is often called a "batch file". In the days of MS-DOS, the extension was always .BAT but these days it is often .cmd. The commands in the file are executed by cmd.exe which is the command-line shell itself. –  steveha Oct 23 '13 at 7:04

Add the program directory to your PATH.

share|improve this answer

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.

share|improve this answer

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.