Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a Linux methodology to include .exe files symbolically to a location referenced by the %PATH%? The process seems trouble free on Linux, but when attempting to do similar actions via mklink on Windows as opposed to ln -s on Linux I always seem to have issues regarding dependencies located in the original application root directory (like binaries, etc.) Thus I would like to know of a concrete example to add application launchers to a PATH location as to enable me to run them conveniently from the command prompt like launching Firefox via simple firefox command?

share|improve this question
2  
Is there a Windows methodology perhaps? Also one problem may be DLL searh order msdn.microsoft.com/en-us/library/windows/desktop/… since on Windows the shared libraries are often relative to the binary. – n611x007 Apr 6 '13 at 11:55
up vote 2 down vote accepted

Create a your_link_name.cmd file where you would want to put the link, with the following contents:

start /D c:/path/to/working/directory c:/path/to/working/directory/example.exe %*

%* should pass any arguments given.

If you need to wait until the process finishes you are better off with psexec from sysinternals, now microsoft, see homepage. I remember start+cmd being buggy in this respect.

psexec -w c:/working_dir c:/working_dir/example.exe %*

In arguments, file paths must be absolute paths on the target system.

share|improve this answer
1  
Note: while / works in windows as a path separator, some executables just don't realize this and won't accept it. Also it doesn't always work with UNC paths with some resources. But psexec and start themselves should have no problems with it. – n611x007 Apr 6 '13 at 12:03
    
I would do a cd before the command (if working directory is applicable) and a pause after (also if needed). – Javier Aug 22 '15 at 20:23
1  
@Javier the /D for the start command, and the -w for the psexec command take care for changing directory. So cd is unnecessary. As for pause, it is useful for manual execution from windows double-clicking to see the output. However from script or from cmd it could stop the script. Even manually I'd prefer running from total commander's prompt and adding |more or 2>&1 |more to its end, the latter showing also the standard error stream. (Actually I use |less from unxutils). If you go with cd you could end the .cmd with a new line @exit /b %errorlevel% to return the exit code. – n611x007 Aug 22 '15 at 20:35
1  
@Javier also, I think start creates a new second window for the command and will not wait in the first window for the second one to finish. So in this case doing pause is tricky. – n611x007 Aug 22 '15 at 20:42
    
I am used to .bat and not using start. Quite more old-school and rudimentary. lol – Javier Aug 22 '15 at 20:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.