3

How can I create a .lnk file using Java? such as I want to create a .lnk file on my desktop which opens the following directory C:\Windows\System32\calc.exe. I have found this website but it is for creating an URL for the website shortcut. it basically write out 2 lines ([InternetShortcut] and URL = XXXXXX.com) by using FileWriter and save it as .URL file. but it seems not working with lnk extension.

Tiny
  • 26,031
  • 99
  • 315
  • 583
pa pa
  • 33
  • 2
  • I was going to say it would be a fun exercise to build your own .link in binary and write it out to that directory. But there is a whole lot more to .lnk files than I would ever have expected. – JoeManiaci Sep 03 '14 at 19:36
  • http://msdn.microsoft.com/en-us/library/dd871305.aspx – Kevin Mangold Sep 03 '14 at 19:38
  • 2
    See [Creating a shortcut file from Java](http://stackoverflow.com/questions/13145942/creating-a-shortcut-file-from-java) – DavidPostill Sep 03 '14 at 19:39
  • Whatever the working method you'll find, it obviously won't be portable... – JSlain Sep 03 '14 at 19:55
  • Faced with the same problem, I ended up using [this program](http://ss64.com/nt/shortcut.html) embedded in the jar file which I copy to the user's home directory at runtime and call with the appropriate parameters. – schmop Sep 03 '14 at 19:56

0 Answers0