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.

Possible Duplicate:
Running programs by typing some alias in Windows

Right now I have Notepad++ (or any other app) in my PATH and can fire it up from the CMD by typing notepad++ < filename > - which is fine. But I'd like to use it like npp < filename > as it's faster and less typing.

Can this be done?

share|improve this question

marked as duplicate by akira, Mehper C. Palavuzlar, ChrisF, Sathya, Nifle Feb 2 '11 at 18:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
superuser.com/questions/193000/… –  akira Jan 31 '11 at 15:07

5 Answers 5

up vote 7 down vote accepted

One solution is to create in the notepad++ directory (or anywhere else in the path) a file called npp.bat that contains the following line :

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

change the above directory, if notepad++ is installed in another directory.

To launch notepad++ without cmd waiting :

@echo off
start "" "C:\Program Files\Notepad++\notepad++.exe" %*
share|improve this answer
    
You'll keep the CMD prompt hung that way. –  paradroid Jan 31 '11 at 13:10
    
@paradroid: To launch notepad++ without cmd waiting can also be done : start "" "C:\Program Files\Notepad++\notepad++.exe" "%1" –  harrymc Jan 31 '11 at 13:19
    
@harrymc: I know, I said that in my answer, and it is better to use "%~1" as the parameter, as that will strip any quotes from a filename that uses them. –  paradroid Jan 31 '11 at 13:20
    
It's even better to use %* (unquoted), to pass unmodified all arguments given to the batch file. –  grawity Jan 31 '11 at 13:25
    
@grawity: Yeah, usually, but Notepad++ has its switches before the filename. –  paradroid Jan 31 '11 at 13:26

One last idea:

The "doskey" utility, available at the NT command line, provides a facility called "macro", which allows you to specify aliases for the command line without having to change your search path or write a batch file for each EXE file you are interested in. Doskey also provides command-line history for old versions of DOS.

Microsoft provides doskey, so you know that it will be on any system you need to use. Doskey has been shipping with Windows (and, before that, MS-DOS) since something like the mid 1990s.

You need to run a command like this once:

doskey /macrofile="c:\somewhere\doskey.macros.txt"

The doskey.macros.txt is a plain text file that has a kind of "alias = command" format, with one alias per line. It looks something like this, with some "unix-like" aliases that I used to use, including the one for npp:

ls = dir $1
mv = move $*
cp = copy $*
cat = type $*
pwd = cd
history = doskey /history
np = "c:\somewhere\notepad++\notepad++.exe" $*
share|improve this answer
    
+1 Forgot all about DOSKEY. –  paradroid Jan 31 '11 at 14:13

Yes you can. Navigate over to C:\Program Files (x86)\Notepad++\ and copy and paste notepad++.exe into the same directory. Now rename the copy to npp.exe. If the directory is in the PATH, you should be able to use npp as you described.

share|improve this answer
    
But this must be redone for each notepad++ release, which are pretty frequent! Not a good solution. –  harrymc Jan 31 '11 at 11:15
    
@harrymc Good point. I do like your solution better. –  James T Jan 31 '11 at 11:24
1  
@harrymc: In Windows 7, this can be done by creating a symlink to notepad++.exe -- works across upgrades. –  grawity Jan 31 '11 at 13:27
1  
@grawity: Why don't you add an answer for symlinks ? –  harrymc Jan 31 '11 at 13:29

You can also create a shortcut to the notepad++.exe file, call it (the shortcut) "npp" and put the location of the shortcut onto your path.

This makes a less verbose alternative to the other answer (creating a bat script for each program you want to do this sort of thing with).

share|improve this answer

This question again? The same answers were given on a question just a few days ago. I can remember.

But here, mklink, this will make a junction, a symlink:

mklink "C:\Program Files\Notepad++\npp.exe" "C:\Program Files\Notepad++\notepad++.exe"
share|improve this answer

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