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