From 4d76e381cbaf6f1f1c4e26376ba182ffa7d2e674 Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 14 Jul 2026 05:29:46 +0000 Subject: [PATCH] Fix windows admin install --- .../io/xpipe/app/core/AppInstallation.java | 28 +++++++++++++++++++ .../io/xpipe/app/update/AppInstaller.java | 11 ++------ .../io/xpipe/app/update/ChocoUpdater.java | 3 +- .../io/xpipe/app/update/WingetUpdater.java | 4 +-- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/core/AppInstallation.java b/app/src/main/java/io/xpipe/app/core/AppInstallation.java index b9f98bca7..f450cd0e7 100644 --- a/app/src/main/java/io/xpipe/app/core/AppInstallation.java +++ b/app/src/main/java/io/xpipe/app/core/AppInstallation.java @@ -50,6 +50,30 @@ public abstract class AppInstallation { }; } + public static AppInstallation.Windows ofWindows() { + if (OsType.ofLocal() != OsType.WINDOWS) { + throw new IllegalStateException(); + } + + return WINDOWS; + } + + public static AppInstallation.Linux ofLinux() { + if (OsType.ofLocal() != OsType.LINUX) { + throw new IllegalStateException(); + } + + return LINUX; + } + + public static AppInstallation.MacOs ofMacOs() { + if (OsType.ofLocal() != OsType.MACOS) { + throw new IllegalStateException(); + } + + return MACOS; + } + private static Path determineDefaultInstallationBasePath(boolean stage) { return switch (OsType.ofLocal()) { case OsType.Linux ignored -> { @@ -178,6 +202,10 @@ public abstract class AppInstallation { super(base); } + public boolean isSystemWide() { + return !getBaseInstallationPath().startsWith(AppSystemInfo.ofWindows().getUserHome()); + } + @Override public Path getDaemonDebugScriptPath() { return getBaseInstallationPath() diff --git a/app/src/main/java/io/xpipe/app/update/AppInstaller.java b/app/src/main/java/io/xpipe/app/update/AppInstaller.java index 6b769d376..0ed3e08dc 100644 --- a/app/src/main/java/io/xpipe/app/update/AppInstaller.java +++ b/app/src/main/java/io/xpipe/app/update/AppInstaller.java @@ -60,7 +60,7 @@ public class AppInstaller { var logsDir = AppLogs.get().getSessionLogsDirectory().getParent().toString(); var logFile = FilePath.of(logsDir, "installer.log"); - var systemWide = isSystemWide(); + var systemWide = AppInstallation.ofWindows().isSystemWide(); var cmdScript = LocalShell.getDialect() == ShellDialects.CMD && !systemWide; var command = cmdScript ? getCmdCommand(file.toString(), logFile.toString()) @@ -93,11 +93,6 @@ public class AppInstaller { return "msi"; } - private boolean isSystemWide() { - return Files.exists( - AppInstallation.ofCurrent().getBaseInstallationPath().resolve("system")); - } - private String getCmdCommand(String file, String logFile) { var args = "MSIFASTINSTALL=7 DISABLEROLLBACK=1"; return String.format( @@ -120,8 +115,8 @@ public class AppInstaller { } private String getPowershellCommand(String file, String logFile, boolean systemWide) { - var property = "MSIFASTINSTALL=7 DISABLEROLLBACK=1" + (systemWide ? " ALLUSERS=1" : ""); - var startProcessProperty = ", MSIFASTINSTALL=7, DISABLEROLLBACK=1" + (systemWide ? ", ALLUSERS=1" : ""); + var property = "MSIFASTINSTALL=7 DISABLEROLLBACK=1" + (systemWide ? " ALLUSERS=1" : " ALLUSERS=0"); + var startProcessProperty = ", MSIFASTINSTALL=7, DISABLEROLLBACK=1" + (systemWide ? ", ALLUSERS=1" : ", ALLUSERS=0"); var runas = systemWide ? "-Verb runAs" : ""; return String.format( """ diff --git a/app/src/main/java/io/xpipe/app/update/ChocoUpdater.java b/app/src/main/java/io/xpipe/app/update/ChocoUpdater.java index 3d61f15eb..386083cea 100644 --- a/app/src/main/java/io/xpipe/app/update/ChocoUpdater.java +++ b/app/src/main/java/io/xpipe/app/update/ChocoUpdater.java @@ -60,8 +60,7 @@ public class ChocoUpdater extends UpdateHandler { var performedUpdate = new PerformedUpdate(p.getVersion(), p.getBody(), p.getVersion()); AppCache.update("performedUpdate", performedUpdate); AppOperationMode.executeAfterShutdown(() -> { - var systemWide = Files.exists( - AppInstallation.ofCurrent().getBaseInstallationPath().resolve("system")); + var systemWide = AppInstallation.ofWindows().isSystemWide(); var propertiesArguments = systemWide ? ", --install-arguments=\"'ALLUSERS=1'\"" : ""; TerminalLaunch.builder() .title("XPipe Updater") diff --git a/app/src/main/java/io/xpipe/app/update/WingetUpdater.java b/app/src/main/java/io/xpipe/app/update/WingetUpdater.java index e6aa43572..4827e0c56 100644 --- a/app/src/main/java/io/xpipe/app/update/WingetUpdater.java +++ b/app/src/main/java/io/xpipe/app/update/WingetUpdater.java @@ -63,9 +63,7 @@ public class WingetUpdater extends UpdateHandler { AppCache.update("performedUpdate", performedUpdate); AppOperationMode.executeAfterShutdown(() -> { TerminalLaunch.builder().title("XPipe Updater").localScript(sc -> { - var systemWide = Files.exists(AppInstallation.ofCurrent() - .getBaseInstallationPath() - .resolve("system")); + var systemWide = AppInstallation.ofWindows().isSystemWide(); var pkgId = "xpipe-io.xpipe"; if (systemWide) { return ShellScript.lines(