1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

Run powershell -Command instead of cmd /c

This commit is contained in:
Reinhard Pointner 2017-02-06 01:09:19 +08:00
parent ddf40be144
commit c701a20bbf

View File

@ -289,17 +289,17 @@ public abstract class ScriptShellBaseClass extends Script {
}
public int execute(Object... args) throws Exception {
Stream<String> cmd = stream(args).map(Objects::toString);
Stream<String> cmd = stream(args).filter(Objects::nonNull).map(Objects::toString);
if (Platform.isWindows()) {
// normalize file separator for windows and run with powershell so any executable in PATH will just work
cmd = Stream.concat(Stream.of("powershell", "-Command"), cmd);
cmd = Stream.concat(Stream.of("powershell", "-NonInteractive", "-NoProfile", "-NoLogo", "-ExecutionPolicy", "Bypass", "-Command"), cmd);
} else if (args.length == 1) {
// make Unix shell parse arguments
cmd = Stream.concat(Stream.of("sh", "-c"), cmd);
}
ProcessBuilder process = new ProcessBuilder(cmd.toArray(String[]::new)).inheritIO();
ProcessBuilder process = new ProcessBuilder(cmd.collect(toList())).inheritIO();
return process.start().waitFor();
}