12

Is it possible to create a Windows shortcut file (.lnk) in Bash?

No, I'm not talking about symlinks...

I need to place some Windows shortcuts in my Samba share.

Lugaxx
  • 685
  • 2
  • 7
  • 16
  • 1
    I found a couple of interesting links: https://msdn.microsoft.com/en-us/library/windows/desktop/bb776891%28v=vs.85%29.aspx#Shellink_Link_Files and https://ithreats.files.wordpress.com/2009/05/lnk_the_windows_shortcut_file_format.pdf . Good luck. – glenn jackman Oct 01 '15 at 14:23
  • IIRC Cygwin includes a utility that creates Windows shortcuts without using using Windows libraries, so it should work on Linux. I don't remember what the utility is called. – Gilles 'SO- stop being evil' Oct 01 '15 at 23:35

1 Answers1

14

Below is a link to a Linux tool which allows you to create Windows shortcuts. The source code is available in both Bash and C:

http://www.mamachine.org/mslink/index.en.html

# Combine with WINE to target a path in a WINE installation
mslink.sh -l "$(winepath -w /linux/path/to/target )" -o /path/to/link.lnk
palswim
  • 4,919
  • 6
  • 37
  • 53
Lugaxx
  • 685
  • 2
  • 7
  • 16
  • Confirmed that mslink can create a shortcut to a UNC path and directory; which is more than I can say for all the Python stuff I was looking at. – Cameron Kerr Aug 17 '18 at 15:06
  • The author created this tool [is a SX user](https://serverfault.com/a/553974/50236), mamachine. – palswim Apr 03 '19 at 19:47
  • @Lugaxx: Would you mind if you or I edited this answer to post some usage examples for the bash script? – palswim Apr 20 '19 at 06:19