Skip to content

Commit

Permalink
Guard against Win32Exception
Browse files Browse the repository at this point in the history
Handle edge-case for missing special folders.
  • Loading branch information
tresf committed Jun 8, 2020
1 parent 9b55aed commit 16de4b4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/qz/installer/WindowsInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public Installer removeLegacyStartup() {
WindowsUtilities.deleteRegKey(HKEY_USERS, user.trim() + "\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\" + ABOUT_TITLE);
}
});
FileUtils.deleteQuietly(new File(STARTUP + File.separator + ABOUT_TITLE + ".lnk"));

try {
FileUtils.deleteQuietly(new File(STARTUP + File.separator + ABOUT_TITLE + ".lnk"));
} catch(Win32Exception ignore) {}

return this;
}
Expand All @@ -68,7 +71,7 @@ public Installer addAppLauncher() {
String exe = destination + File.separator + PROPS_FILE+ ".exe";
log.info("Creating launcher \"{}\" -> \"{}\"", lnk, exe);
ShellLink.createLink(exe, lnk);
} catch(IOException e) {
} catch(IOException | Win32Exception e) {
log.warn("Could not create launcher", e);
}
return this;
Expand All @@ -81,7 +84,7 @@ public Installer addStartupEntry() {
log.info("Creating startup entry \"{}\" -> \"{}\"", lnk, exe);
ShellLink link = ShellLink.createLink(exe, lnk);
link.setCMDArgs("--honorautostart"); // honors auto-start preferences
} catch(IOException e) {
} catch(IOException | Win32Exception e) {
log.warn("Could not create startup launcher", e);
}
return this;
Expand All @@ -100,8 +103,10 @@ public Installer removeSystemSettings() {
new File(folder + File.separator + ABOUT_TITLE + ".lnk").delete();
// Since 2.1, start menus use subfolder
if (folder.equals(COMMON_START_MENU) || folder.equals(START_MENU)) {
FileUtils.deleteQuietly(new File(folder + File.separator + "Programs" + File.separator + ABOUT_TITLE + ".lnk"));
FileUtils.deleteDirectory(new File(folder + File.separator + "Programs" + File.separator + ABOUT_TITLE));
try {
FileUtils.deleteQuietly(new File(folder + File.separator + "Programs" + File.separator + ABOUT_TITLE + ".lnk"));
FileUtils.deleteDirectory(new File(folder + File.separator + "Programs" + File.separator + ABOUT_TITLE));
} catch(Win32Exception ignore) {}
}
} catch(IOException ignore) {}
}
Expand Down

0 comments on commit 16de4b4

Please sign in to comment.