Create shortcut in windows programmatically

假如想象 提交于 2019-12-04 03:36:39

问题


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?


回答1:


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.




回答2:


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




回答3:


I suggest you to create a shortcut manually and then copy it programatically into the desktop folder. c:\users\desktop



来源:https://stackoverflow.com/questions/19629034/create-shortcut-in-windows-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!