Skip to content

Commit

Permalink
replaced deprecated ShellLink.createLink calls
Browse files Browse the repository at this point in the history
Fixes qzind#971
  • Loading branch information
Vzor- committed May 9, 2022
1 parent 7be96b2 commit 521e186
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/qz/installer/WindowsInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import com.sun.jna.platform.win32.*;
import mslinks.ShellLink;
import mslinks.ShellLinkException;
import mslinks.ShellLinkHelper;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -70,8 +72,8 @@ public Installer addAppLauncher() {
String lnk = loc + File.separator + ABOUT_TITLE + ".lnk";
String exe = destination + File.separator + PROPS_FILE+ ".exe";
log.info("Creating launcher \"{}\" -> \"{}\"", lnk, exe);
ShellLink.createLink(exe, lnk);
} catch(InvalidPathException | IOException | Win32Exception e) {
ShellLinkHelper.createLink(exe, lnk);
} catch(ShellLinkException | IOException | Win32Exception e) {
log.warn("Could not create launcher", e);
}
return this;
Expand All @@ -82,9 +84,9 @@ public Installer addStartupEntry() {
String lnk = WindowsSpecialFolders.COMMON_STARTUP + File.separator + ABOUT_TITLE + ".lnk";
String exe = destination + File.separator + PROPS_FILE+ ".exe";
log.info("Creating startup entry \"{}\" -> \"{}\"", lnk, exe);
ShellLink link = ShellLink.createLink(exe, lnk);
ShellLink link = ShellLinkHelper.createLink(exe, lnk).getLink();
link.setCMDArgs("--honorautostart"); // honors auto-start preferences
} catch(InvalidPathException | IOException | Win32Exception e) {
} catch(ShellLinkException | IOException | Win32Exception e) {
log.warn("Could not create startup launcher", e);
}
return this;
Expand Down
7 changes: 4 additions & 3 deletions src/qz/installer/shortcut/WindowsShortcutCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

package qz.installer.shortcut;

import mslinks.ShellLink;
import mslinks.ShellLinkException;
import mslinks.ShellLinkHelper;
import qz.common.Constants;
import qz.installer.WindowsSpecialFolders;
import qz.utils.SystemUtilities;
Expand All @@ -36,9 +37,9 @@ public boolean canAutoStart() {

private void createShortcut(String folderPath) {
try {
ShellLink.createLink(getAppPath(), folderPath + File.separator + SHORTCUT_NAME);
ShellLinkHelper.createLink(getAppPath(), folderPath + File.separator + SHORTCUT_NAME);
}
catch(InvalidPathException | IOException ex) {
catch(ShellLinkException | IOException ex) {
log.warn("Error creating desktop shortcut", ex);
}
}
Expand Down

0 comments on commit 521e186

Please sign in to comment.