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

时间:2010-08-06 17:44:02

标签: java scripting vbscript shortcut

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

我对任何想法感兴趣是最好的方法。我考虑的一个选项是在Windows上使用VB脚本并使用本机'shortcut.exe'为我做,但是第三方文件实用程序将是首选。

2 个答案:

答案 0 :(得分:2)

  /**
   * 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 (Windows)

答案 1 :(得分:0)

请参阅this similar question.this

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

相关问题