Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Java创建快捷链接(.lnk)_Java_Scripting_Vbscript_Shortcut - Fatal编程技术网

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

从Java创建快捷链接(.lnk),java,scripting,vbscript,shortcut,Java,Scripting,Vbscript,Shortcut,我正在用Java编写一个安装程序(launcher),需要能够在这个过程中在用户桌面上创建快捷方式 我对任何想法都感兴趣,认为这是最好的方法。我考虑过的一个选择是在windows上使用VB脚本,并使用本机的“shortcut.exe”为我执行此操作,但最好使用第三方文件实用程序。请参阅和 在谷歌快速搜索后,我找到了这个java库: 此处完整示例:为什么不直接调用shortcut.exe而不使用VBS? /** * Create an Internet shortcut * @pa

我正在用Java编写一个安装程序(launcher),需要能够在这个过程中在用户桌面上创建快捷方式

我对任何想法都感兴趣,认为这是最好的方法。我考虑过的一个选择是在windows上使用VB脚本,并使用本机的“shortcut.exe”为我执行此操作,但最好使用第三方文件实用程序。

请参阅和

在谷歌快速搜索后,我找到了这个java库:


此处完整示例:

为什么不直接调用shortcut.exe而不使用VBS?
  /**
   * 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();
  }