23

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.

So is there any way to execute a symlink?

EDIT: In the command prompt, I execute the following and the MyProgram.exe runs both times. However, if I double-click on the symbolic link in Windows Explorer it fails with the above error message.

C:\Temp>mklink SomeProgram.exe MyProgram.exe
symbolic link created for Backup.exe <<===>> Backup-1.0.1.exe

C:\Temp>SomeProgram.exe

C:\Temp>del SomeProgram.exe

C:\Temp>mklink SomeProgram.exe C:\Temp\MyProgram.exe
symbolic link created for Backup.exe <<===>> C:\Temp\Backup-1.0.1.exe

C:\Temp>SomeProgram.exe
3
  • 1
    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.) Jun 29, 2011 at 19:43
  • @grawity: Not true. Symlinks can use absolute as well as relative paths on *nix. Also, he mentioned Windows 7. Jun 29, 2011 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. Jun 29, 2011 at 19:49

3 Answers 3

10

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 discovered the problem.

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.)

3
  • I have LSE installed but where can I find LSEConfig.exe? Jun 27, 2012 at 12:33
  • Ah I needed to install the latest version. It wasn't there before. Jun 27, 2012 at 15:49
  • 5
    Absolute links don't work any better than relative links for me under Windows 7 32-bit. At least not when made via mklink [absolutelink] [absolutetarget].
    – weberc2
    Oct 10, 2012 at 17:16
6

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

4
  • 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, 2011 at 18:55
  • 1
    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, 2011 at 6:21
  • 4
    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, 2011 at 2:00
  • 1
    Downvote for failure to address actual issue.
    – weberc2
    Oct 10, 2012 at 17:13
2

Quite a necro, but I still had the same question and this was the only one addressing this issue.

But here is my workaround! If "C:\app.exe" gives you trouble for not launching because of explorer, just create "app.bat", with "C:\app.exe" as contents. Launching app.bat will launch app.exe from the command line.

The problem is now that it executes it from the location of app.exe, so relative links in the .exe might give trouble now, only simple programs work. You can still make a .bat that goes to the target location and then runs the .exe, but we're miles from "just a symlink" then.

You must log in to answer this question.

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