As a developer, I install and run many applications. To access these from the command-line, the usual mechanism to add the applications to the PATH environment variable. That's ok, but leads to a messy, large, impenetrable PATH.
I want to tidy this up by having a single directory, e.g. c:\dev
that contains symlinks to all the applications. I can create the symlinks fine with mklink, e.g. mklink eclipse.exe c:\dev\eclipse\eclipse.exe
.
For the Eclipse example, when I try the new symlink, I get an error about a companion library. For other apps (e.g. Notepad++) I get a different error.
HOWEVER, when I type the same path directly into the command line, e.g. c:\dev\eclipse\eclipse.exe
everything works.
So, a symlink eclipse.exe => c:\dev\eclipse.exe
is different to plain c:\dev\eclipse.exe
. I was hoping (sigh) and assuming (doh!) that the symlink would work the same as directly typing the full path.
IOW, why is symlink => c:\dev\eclipse.exe
not equivalent to typing c:\dev\eclipse.exe
?
Is there any way around this? I know I can write little batch files, but I was hoping to avoid that (symlinks seem cleaner).
Is this a Windows idiosyncrasy or is Linux the same?
Best Answer
Let me illustrate the problem with an example. I created a simple one-line batch file Test.bat in
C:\Program Files
with the following contents:Now from
D:\
if I invoke the batch file withC:\Program Files\Test
, it says:If I modify the PATH using
set path=%path%;C:\Program Files
and invoke the batch file with a simpleTest
, it says:Finally if I create a symlink using
mklink Test.bat "C:\Program Files\Test.bat"
and invoke it with a simpleTest
, it says:As you can see the current working directory is different in this case. No wonder your apps are complaining about files they expect in the executable's directory being missing.
If you don't want to add lots of directories to the PATH just add one that contains batch files for each of your apps.