From 16de4b4052994fa8072a66b9c88d35bd58134776 Mon Sep 17 00:00:00 2001 From: tresf Date: Mon, 8 Jun 2020 12:44:26 -0400 Subject: [PATCH] Guard against Win32Exception Handle edge-case for missing special folders. --- src/qz/installer/WindowsInstaller.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/qz/installer/WindowsInstaller.java b/src/qz/installer/WindowsInstaller.java index 1b74dde7c..b7e7cc153 100644 --- a/src/qz/installer/WindowsInstaller.java +++ b/src/qz/installer/WindowsInstaller.java @@ -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; } @@ -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; @@ -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; @@ -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) {} }