mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-07-31 09:06:11 -04:00
Fix windows admin install
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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(
|
||||
"""
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user