Hello,
i need restart & shutdown computer for all platforms (windows, mac, Linux)
i tried with Jshell but i cant success. Below code always return Exit code: 1
I found that code on GitHub. is it possible convert this code to b4j
i need restart & shutdown computer for all platforms (windows, mac, Linux)
i tried with Jshell but i cant success. Below code always return Exit code: 1
B4X:
Dim shl As Shell
shl.Initialize("shl", "shutdown.exe", Array As String("-s -t 0"))
shl.WorkingDirectory = "C:\Windows\System32\"
shl.Run(10000) 'set a timeout of 10 seconds
I found that code on GitHub. is it possible convert this code to b4j
B4X:
public static void shutdown() throws RuntimeException, IOException {
String shutdownCommand;
String operatingSystem = System.getProperty("os.name");
if ("Linux".equals(operatingSystem) || "Mac OS X".equals(operatingSystem)) {
shutdownCommand = "shutdown -h now";
}
else if ("Windows".equals(operatingSystem)) {
shutdownCommand = "shutdown.exe -s -t 0";
}
else {
throw new RuntimeException("Unsupported operating system.");
}
Runtime.getRuntime().exec(shutdownCommand);
System.exit(0);
}