3

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?

1

5 Answers 5

7

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" %*
9
  • You'll keep the CMD prompt hung that way.
    – paradroid
    Jan 31, 2011 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, 2011 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, 2011 at 13:20
  • 1
    It's even better to use %* (unquoted), to pass unmodified all arguments given to the batch file. Jan 31, 2011 at 13:25
  • @grawity: Yeah, usually, but Notepad++ has its switches before the filename.
    – paradroid
    Jan 31, 2011 at 13:26
4

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" $*
0
2

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.

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

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

0

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"

Not the answer you're looking for? Browse other questions tagged .