3

Say, for example, I were to use wget on Windows. If I extract the zip file, it has a whole lot of dependencies (dlls etc.) Now if I were to symlink wget.exe (using mklink) to my desktop (I've tried with both symbolic links and hard links), it still doesn't work without the requisite dlls being placed on the desktop too/being symlinked to the desktop too. Is there a way I can get it to run from the desktop, but "see" the dependencies back in its own folder?

Note that if I was to create a shortcut to wget.exe on my Desktop, I can easily bring it up from the Command Prompt with the Desktop as the location, and it works as expected, but I have to run wget.exe.lnk. Can I get a symlink to behave like this (without the .lnk of course)?

Thanks!

2
  • I'm not sure if this solves the problem, but are the dependencies located somewhere in your PATH (like System32)? Windows doesn't really have separate "binaries" and "libraries" paths the way *nix does, but the PATH environment variable is used when looking for libraries. Of course, if you mean stuff like looking for text files saved alongside the binary, yeah, that won't work.
    – CBHacking
    Commented Sep 20, 2015 at 10:51
  • Yep, that's what I was referring to. Isn't there a way of getting it to work? Logically I would've thought a symlink should work and a hardlink wouldn't, because a symlink is more like a shortcut. Commented Sep 20, 2015 at 16:09

2 Answers 2

2

There is an alternative solution; use a batch file to call the exe, instead of using a link (or as well as).

e.g. I have a folder c:\utils\path into which I drop all single-file-exes that I want to run by program name regardless of path (i.e. this folder is in my %path% environment variable; thus avoiding me having to add new directories for each utility).

I have an app which requires DLLs from its local path (e.g. make) where I don't want to copy all its DLLs to my c:\utils\path directory, so lives under its default install path (C:\Program Files (x86)\GnuWin32\bin\).

I can create a batch file, make.bat with the following content; which then acts like a symlink for the exe:

"C:\Program Files (x86)\GnuWin32\bin\make.exe" %*

i.e. The batch calls the exe, giving its full path (so it finds the DLLs in its local directory), and passing on any arguments (%*) that were passed to the batch file.

This batch file can be placed directly under my path directory c:\utils\path; or can be placed alongside its related exe (C:\Program Files (x86)\GnuWin32\bin\) with a symlink from my path directory targeting the batch instead of the exe.

Side Note: sadly using "%~dp0\make.exe" %* in the batch script won't work; as %~dp0 resolves to the symlink's directory, rather than its target's. That said, that's not really an issue; as we know the exe's full path and it's unlikely to move around.

4

Short answer: No.

For the record, this does not even work in Linux/Unix where symlinks are the norm. In any command-line environment, if a binary has dependencies, they must either be in the current working directory, or in one of the directories in your PATH variable.

In your case, you could hardlink the directory onto your desktop, but you would still have to CD into it from the command line before you ran wget.exe.

The only alternative would be to recompile wget.exe and statically link it against the .dll files it requires (since it's open source). That way you would not need those .dlls and wget.exe would be a stand-alone executable. The steps for doing this in Windows, however, are a bit beyond the scope of SuperUser.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .