Is there a way to create link in windows?
I found samples that use VBScript
or one has to do download Shortcut.exe
.
I need a simple solution. Is that possible?
Asked
Active
Viewed 1.0k times
6
-
see http://stackoverflow.com/questions/606820/is-there-a-java-library-to-access-the-native-windows-api and http://stackoverflow.com/questions/2389156/calling-win32-api-method-from-java – siledh Oct 28 '13 at 07:21
-
You can run VB script from Java. – Peter Lawrey Oct 28 '13 at 07:22
-
If the app. has a GUI, the best option is usually to install it using [Java Web Start](http://stackoverflow.com/tags/java-web-start/info). JWS works on Windows, OS X & *nix, and provides support for desktop shortcuts, start menu items and file associations. – Andrew Thompson Oct 28 '13 at 08:05
3 Answers
17
I had the same problem, so i wrote library for parsing and creating .lnk files. It does not use VBScripts or JNI, java code only. See my Github.
Creating shortcuts: ShellLink.createLink("targetfile", "linkfile.lnk")
. You can also set up most parameters of the link. See details and examples in repo.
Probably this question is not actual already, but i hope it will be helpfull for people who will find this topic in Google.

BlackOverlord
- 388
- 4
- 14
-
This `mslinks` library works well. Only potential downside to users is compiling it by hand (To the author of the library, I do recommend offering a jar download via `mslinks/releases`). Works very well for simply linking a `.exe` to a target location. As illustrated in the comment above, the code is a one-liner after the library/api has been imported. – tresf Apr 12 '16 at 03:32
-
@BlackOverlord this is great! Do you know of a way to set the shortcut to "Run as administrator" by default as well? – TragedyStruck Jan 04 '18 at 21:16
0
Well, I had to use Shortcut.exe
to create shortcut but actually what I needed was a HardLink
to a folder but Shortcut.exe
would create a SoftLink
.
Eventually I used junction.exe
to create the HardLink
.
Check this post for more information https://stackoverflow.com/questions/46885/how-to-create-symbolic-links-in-windows