Cygwin to execute windows shortcut files (.LNK)

7

1

I use Cygwin as my cmd replacement on Windows and I am in the process of cleaning up my system PATH variable.

I now have a folder containing exe's and shortcuts (.LNK) files which is in PATH containing all the small apps and software I use from the command line.

Everything works through CMD, however the shortcuts, .LNK files, do not work through Cygwin. Instead I get

bash: /cygdrive/e/Apps/uniserver.lnk: cannot execute binary file

My only guess is because it thinks .lnk is supposed to be a symlink?

Is there anyway to get Cygwin to launch the shortcut?

binarysmacker

Posted 2014-07-30T11:52:43.483

Reputation: 193

If you need to know where a shortcut points (a slightly different issue), you can use readshortcut foo.lnk. (Leaving a comment here so I'll be able to find the information again myself in the future :) .) – cxw – 2018-04-26T14:31:53.567

Answers

6

You can execute Windows LNK files from Cygwin using the cygstart utility, part of cygutils package, as follows:

cygstart [OPTION]... FILE [ARGUMENTS]

See cygstart --help for the options available.

The following should be enough in your case:

cygstart /cygdrive/e/Apps/uniserver.lnk

famousgarkin

Posted 2014-07-30T11:52:43.483

Reputation: 182

0

Use the DOS built-in command start. I'm guessing Cygwin does NOT have access to DOS built-ins, though, so you'll have to write a wrapper, like mystart.bat, and launch your LNK's my using the wrapper script.

I don't think you can "associate" the LNK files in Cygwin to make Cygwin automatically launch your wrapper, but perhaps someone else can suggest a way to do that.

jimtut

Posted 2014-07-30T11:52:43.483

Reputation: 832