从 Java 创建快捷链接 (.lnk)

发布于 2024-09-13 09:21:36 字数 161 浏览 8 评论 0原文

我正在用 Java 编写一个安装程序(启动器),并且需要能够在此过程中在用户桌面上创建快捷方式。

我对任何想法都感兴趣,认为这是实现这一目标的最佳方法。我考虑过的一个选择是在 Windows 上使用 VB 脚本并使用本机“shortcut.exe”来为我完成此操作,但首选第三方文件实用程序。

I am writing an installer (launcher) in Java and require the ability to be able to create a shortcut on the users desktop during the process.

I am interested in any ideas as the best way to do this. My one option I have considered is using a VB Script on windows and using the native 'shortcut.exe' to do it for me, however a third party file utility would be preferred.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

辞慾 2024-09-20 09:21:39

请参阅这个类似的问题。这个

经过快速谷歌搜索后,我找到了这个java库: http://alumnus.caltech.edu/~ jimmc/jshortcut/

See this similar question. and this.

After a quick google search I found this java library: http://alumnus.caltech.edu/~jimmc/jshortcut/

我不吻晚风 2024-09-20 09:21:38
  /**
   * Create an Internet shortcut
   * @param name     name of the shortcut
   * @param where    location of the shortcut
   * @param target   URL 
   * @param icon     URL (ex. http://www.server.com/favicon.ico)
   * @throws IOException
   */
  public static void createInternetShortcut
      (String name, String where, String target, String icon) 
    throws IOException
  {
    FileWriter fw = new FileWriter(where);
    fw.write("[InternetShortcut]\n");
    fw.write("URL=" + target + "\n");
    if (!icon.equals(""))  {
      fw.write("IconFile=" + icon + "\n");  
    }
    fw.flush();
    fw.close();
  }
  /**
   * Create an Internet shortcut
   * @param name     name of the shortcut
   * @param where    location of the shortcut
   * @param target   URL 
   * @param icon     URL (ex. http://www.server.com/favicon.ico)
   * @throws IOException
   */
  public static void createInternetShortcut
      (String name, String where, String target, String icon) 
    throws IOException
  {
    FileWriter fw = new FileWriter(where);
    fw.write("[InternetShortcut]\n");
    fw.write("URL=" + target + "\n");
    if (!icon.equals(""))  {
      fw.write("IconFile=" + icon + "\n");  
    }
    fw.flush();
    fw.close();
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文