1

I'm trying to create an environment variable for my cmd so that I can launch Notepad++ without having to type in the full path.

I created an environment variable called NPAD which holds the directory where my Notepad++ executable is saved.

echo %NPAD% C:\PROG\Resources\Notepad++ 

the shortcut that launches it is called npedit.lnk

When I try to execute it I have to type

%NPAD%\npedit.lnk 

Is there a way to make it run just by using

npedit.lnk 

Without directly using the NPAD environment variable, for example I can use java with just

java 
2
  • 1
    npedit.lnk has to be in your %path% to work like java. Also set "npad=C:\PROG\Resources\Notepad++\npedit.lnk" may be an option. I personally have a batchfile n+.bat within my path with just one line: @"C:\PortableApps\Notepad++Portable\notepad++.exe" %* Commented Jan 12, 2016 at 13:11
  • This was really helpful, would you mind posting these options as an answer, the batch file was my favorite of the options Commented Jan 12, 2016 at 14:02

1 Answer 1

3

Java works, because it's in your %path%. To work npedit.lnk like this, you either have to put it into a folder defined by your %path% variable or add the directory of npedit.lnk to the %path% variable.

But you have more Options:

set "npad=C:\PROG\Resources\Notepad++\npedit.lnk" 

(setx npad C:\PROG\Resources\Notepad++\npedit.lnk" for a permanent setting)

or (I use this) a batchfile (for example) n+.bat within the %path% with just one line:

@"C:\PortableApps\Notepad++Portable\notepad++.exe" %* 

(adapt the path to your settings).

%* routes any parameters to Notepad++, so you can just type n+ myfile.bat to edit a specific file.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.