Fix windows admin install

This commit is contained in:
crschnick
2026-07-14 05:29:46 +00:00
parent fbd29b9e52
commit 4d76e381cb
4 changed files with 33 additions and 13 deletions

View File

@@ -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()

View File

@@ -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(
"""

View File

@@ -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")

View File

@@ -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(