我正在用Java编写安装程序(启动器),需要在过程中能够在用户桌面上创建快捷方式。
我对任何想法都很感兴趣,以找到最佳方法。我考虑的一个选项是在Windows上使用VB脚本并使用本地的“shortcut.exe”来为我完成它,但最好使用第三方文件实用程序。
/**
* 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();
}