Managing Path Dependencies

So you’ve got some commandline tools but they each depend on a bunch of dlls? You could dump the whole mess together in one dir, but that’d be awful. Adding a dozen tool-specific dirs to your PATH isn’t pretty either. The answer: symlinks!
 
What’s that? Windows doesn’t have symlinks? How about shortcuts? No luck there. Well there are still batch files…
 

C:/UnixUtils/
C:/UnixUtils/BloatedCmd/
C:/UnixUtils/BloatedCmd/some.dll
C:/UnixUtils/BloatedCmd/bloated.exe
C:/UnixUtils/BloatedCmd/runme.bat
C:/UnixUtils/bloated.bat
 
– Add UnixUtils to your PATH.
– Make a subdir for each command that has a dll posse.
– Create a runme.bat frontend for any preset args you ever plan on using.

@echo off
“%~dp0bloated.exe” -a -r -g %*
exit /B %ERRORLEVEL%

 
– Create a bloated.bat in the UnixUtils dir.

@echo off
call “%~dp0BloatedCmd\runme.bat” %*
exit /B %ERRORLEVEL%

 
%~dp0 is shorthand for the location of the current bat.
%* relays any args that were passed to the current bat.
If you’re checking the command’s return code, that’ll be preserved too.
 

Now you’ll be able to run that command from anywhere.
One caveat: Within future scripts, you have to write “call bloated”.

Tags:

Leave a Reply