mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-09 03:46:18 -04:00
Update script format
This commit is contained in:
parent
67feca075b
commit
16952f5695
@ -491,12 +491,12 @@ public class DefaultLauncher extends Launcher {
|
|||||||
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, charset))) {
|
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, charset))) {
|
||||||
if (usePowerShell) {
|
if (usePowerShell) {
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
writer.write("$Env:APPDATA = ");
|
writer.write("$Env:APPDATA=");
|
||||||
writer.write(CommandBuilder.pwshString(options.getGameDir().getAbsoluteFile().getParent()));
|
writer.write(CommandBuilder.pwshString(options.getGameDir().getAbsoluteFile().getParent()));
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, String> entry : getEnvVars().entrySet()) {
|
for (Map.Entry<String, String> entry : getEnvVars().entrySet()) {
|
||||||
writer.write("$Env:" + entry.getKey() + " = ");
|
writer.write("$Env:" + entry.getKey() + "=");
|
||||||
writer.write(CommandBuilder.pwshString(entry.getValue()));
|
writer.write(CommandBuilder.pwshString(entry.getValue()));
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
@ -509,6 +509,7 @@ public class DefaultLauncher extends Launcher {
|
|||||||
writer.write(' ');
|
writer.write(' ');
|
||||||
writer.write(CommandBuilder.pwshString(rawCommand));
|
writer.write(CommandBuilder.pwshString(rawCommand));
|
||||||
}
|
}
|
||||||
|
writer.newLine();
|
||||||
} else {
|
} else {
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
writer.write("@echo off");
|
writer.write("@echo off");
|
||||||
@ -550,9 +551,9 @@ public class DefaultLauncher extends Launcher {
|
|||||||
}
|
}
|
||||||
if (!scriptFile.setExecutable(true))
|
if (!scriptFile.setExecutable(true))
|
||||||
throw new PermissionException();
|
throw new PermissionException();
|
||||||
if (usePowerShell && !CommandBuilder.hasExecutionPolicy()) {
|
|
||||||
|
if (usePowerShell && !CommandBuilder.hasExecutionPolicy())
|
||||||
throw new ExecutionPolicyLimitException();
|
throw new ExecutionPolicyLimitException();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startMonitors(ManagedProcess managedProcess, ProcessListener processListener, boolean isDaemon) {
|
private void startMonitors(ManagedProcess managedProcess, ProcessListener processListener, boolean isDaemon) {
|
||||||
|
@ -187,8 +187,8 @@ public final class CommandBuilder {
|
|||||||
return "Unrestricted".equalsIgnoreCase(policy) || "RemoteSigned".equalsIgnoreCase(policy);
|
return "Unrestricted".equalsIgnoreCase(policy) || "RemoteSigned".equalsIgnoreCase(policy);
|
||||||
}
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean setExecutionPolicy() {
|
public static boolean setExecutionPolicy() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user