prompt for separate user-installs too

This commit is contained in:
idk
2022-09-19 20:03:57 -04:00
parent 6b61213625
commit 4aa4763770
2 changed files with 49 additions and 0 deletions

View File

@@ -94,6 +94,12 @@ public class WinLauncher extends CopyConfigDir {
"Service startup failure, please start I2P service with services.msc");
System.exit(2);
}
continuerunning = promptUserInstallStartIfAvailable();
if (!continuerunning) {
logger.severe(
"User-install startup required.");
System.exit(2);
}
// This actually does most of what we use NSIS for if NSIS hasn't
// already done it, which essentially makes this whole thing portable.

View File

@@ -1,6 +1,7 @@
package net.i2p.router;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JOptionPane;
@@ -142,6 +143,48 @@ public class WindowsServiceUtil {
return "http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/news.su3";
}
public static boolean checkProgramFilesInstall() {
String programFiles = System.getenv("PROGRAMFILES");
File programFilesI2P = new File(programFiles, "i2p/i2p.exe");
if (programFilesI2P.exists())
return true;
String programFiles86 = System.getenv("PROGRAMFILES86");
File programFiles86I2P = new File(programFiles86, "i2p/i2p.exe");
if (programFiles86I2P.exists())
return true;
return false;
}
public static boolean promptUserInstallStartIfAvailable() {
if (osName() != "windows") {
return true;
}
if (checkProgramFilesInstall()) {
int a;
String message =
"It appears you have an existing, unbundled I2P rotuer installed.\n";
message +=
"However, it is not running yet. Please start it using the shortcut on the desktop.\n";
message +=
"If you click \"No\", the jpackage router will be launched instead.\n";
a = JOptionPane.showConfirmDialog(null, message,
"I2P Service detected not running",
JOptionPane.YES_NO_OPTION);
if (a == JOptionPane.NO_OPTION) {
// 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;
}
}
return true;
}
public static String getServiceState(String serviceName) {
String stateString = "uninstalled";
int state = getServiceStateInt(serviceName);