Custom commands in windows Command Prompt
How do I write a custom command to open files with Notepad++ text editor in Windows Command prompt.
For eg.
C:\S开发者_开发知识库ites>ntp abc.txt
opens the file abc.txt in Notepad++
Create a batch file containing this line
@START c:\Program Files\Notepad++\notepad++.exe "%1"
and put it into some directory that is in your PATH list (or, alternatively, add a directory with a .bat file to PATH).
You can use doskey
. Try:
doskey ntp=notepadpp.exe
and now you can do simply:
ntp blah.txt
Create a .bat file and save it as npt.bat
In that file put the following line of code (or change it to match the path to your notepad++.exe))
@START c:\"Program Files (x86)"\Notepad++\notepad++.exe "%1"
Note that you need quotation marks around any parts of the path with spaces in it.
Now place it in whatever directory you like and add the directory to PATH in your User variables.
You can also create a bat file which does what you wish (mentioned in other answers here), then put it in C:\Windows\System32.
Execute it by writing the name of the file. For example ntp
if your file was named ntp.bat
Make sure that you restart the command line before trying your new super cool custom command.
suppose we use 3 different versions of python and want to refer to each as commands like:
python36 -m pip install numpy
python38 -m pip list
python310 --version
just create a file called "python36.cmd" and write this one line in it
"C:\Program Files\Python36\python.exe" %*
and put it in a directory that is already in the PATH. If you use VSCode then its bin directory will already be in PATH variable. so put the python36.cmd file there.
In addition to the answer of @Kaerber
This works for me
@START c:\"Program Files"\Notepad++\notepad++.exe "%1"
While this doesn't work (and just opens the explorer)
@START "c:\Program Files\Notepad++\notepad++.exe" "%1"
精彩评论