When trying to execute a symbolic link which points to an exe file (on Windows 7), the "Open with" windows appears. When renaming it to a ".exe" file, it says "The specified path does not exist. Check the path, and then try again.". Symlinks to other destinations seem to work fine.

I know that because hard links are a reference to the file's inode, they do not have this issue. But because of their disadvantages (like replacing "target file" not possible), I avoid hard links. And Windows shortcuts (lnk files) aren't filesystem links. Although I haven't had any trouble with them yet, I'd rather avoid them as well.

So is there any way to execute a symlink?

link|improve this question

29% accept rate
Make sure your symlinks point to the right place - the target is relative to the link's location, not to the current directory when creating a link. (This bites *nix users often.) – grawity Jun 29 '11 at 19:43
@grawity: Not true. Symlinks can use absolute as well as relative paths on *nix. Also, he mentioned Windows 7. – pipitas Jun 29 '11 at 19:46
@pipitas: You're right that symlinks can use absolute paths (I never said otherwise), it's just that people often use ln -s ../../foo somedir/bar and get the wrong thing. || Symlinks work exactly the same way in both *nix and Windows. – grawity Jun 29 '11 at 19:49
feedback

2 Answers

up vote 1 down vote accepted

Works for me....

D:\Develop\DateTouch>mklink foo.exe TouchDate.exe
symbolic link created for foo.exe <<===>> TouchDate.exe

D:\Develop\DateTouch>foo.exe

How are you creating the symbolic link?


Edit:

enter image description here

  • Windows 7 Service Pack 1 applied?
  • 64-bit?

Edit: i see an issue:

C:\Users\ian.AVATOPIA>mklink foo4.exe c:\asdfasdf\adfasdf.exe
symbolic link created for foo4.exe <<===>> c:\asdfasdf\adfasdf.exe

So make sure your file actually exists.


Edit: i think i see your issue:

  • it launches fine from a command prompt
  • it fails to launch from Windows Explorer:

enter image description here

link|improve this answer
That's exactly what I'm doing. "mklink foo.exe c:\windows\system32\notepad-exe" or if notepad is in the current directory "mklink foo2.exe notepad.exe". When trying to open foo.exe or foo2.exe, I get said error message. Note that I can open the files with a text editor by replacing ".exe" with ".txt", so the target of the symlink is correct. – basic6 Jun 30 '11 at 18:55
YES, that's it! The holy Explorer refuses to execute symlinks, but the Windows command prompt and other file managers like muCommander don't. That solves my problem - thanks! – basic6 Jul 1 '11 at 6:21
Well it doesn't solve the problem; but it explains how to reproduce it. i couldn't find anything in process monitor that would hint why Explorer fails to launch it. i even wrote an application and call ShellExecute, and it launches fine. – Ian Boyd Jul 3 '11 at 2:00
feedback

Since the only other answer doesn't really "fix" the issue, just acknowledges it, I think it's worth saying I had this same issue, and resolved it.

The issue for me was relative vs absolute symlinks. I use Link Shell Extension.

When creating absolute symlinks, Explorer works fine. When creating relative links, Explorer chokes on them.

I can only guess that this is somehow related to how Explorer calculates the working directory? Maybe some slash problems?

(Note that on Win7 x64, at least, you may have to open LSEConfig.exe after installing the extension, and toggle Absolute and then Relative to get it to make relative links, as the default config is somewhat unpredictable, sometimes relative, sometimes absolute.)

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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