diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index d982941..d0a268b 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -96,8 +96,7 @@ public class WinLauncher extends CopyConfigDir { } continuerunning = promptUserInstallStartIfAvailable(); if (!continuerunning) { - logger.severe( - "User-install startup required."); + logger.severe("User-install startup required."); System.exit(2); } diff --git a/java/net/i2p/router/WindowsServiceUtil.java b/java/net/i2p/router/WindowsServiceUtil.java index b7d8fff..15ca52d 100644 --- a/java/net/i2p/router/WindowsServiceUtil.java +++ b/java/net/i2p/router/WindowsServiceUtil.java @@ -143,6 +143,17 @@ public class WindowsServiceUtil { return "http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/news.su3"; } + public static String getProgramFilesInstall() { + String programFiles = System.getenv("PROGRAMFILES"); + File programFilesI2P = new File(programFiles, "i2p/i2p.exe"); + if (programFilesI2P.exists()) + return programFilesI2P.getAbsolutePath(); + String programFiles86 = System.getenv("PROGRAMFILES86"); + File programFiles86I2P = new File(programFiles86, "i2p/i2p.exe"); + if (programFiles86I2P.exists()) + return programFiles86I2P.getAbsolutePath(); + } + public static boolean checkProgramFilesInstall() { String programFiles = System.getenv("PROGRAMFILES"); File programFilesI2P = new File(programFiles, "i2p/i2p.exe"); @@ -174,12 +185,12 @@ public class WindowsServiceUtil { // Do nothing here, this will continue on to launch a jpackaged router return true; } else { - // We can't just call `net start` or `sc start` directly, that throws - // a permission error. We can start services.msc though, where the - // user can start the service themselves. OR maybe we ask for - // elevation here? May need to refactor Elevator and Shell32X to - // achieve it though - return false; + try { + Runtime.getRuntime().exec(getProgramFilesInstall()); + } catch (IOException e) { + return false; + } + return true; } } return true;