Exemplo n.º 1
0
  private static String executeCommand(String commandName, String... args) {
    CommandLine cmd = new CommandLine(commandName, args);
    cmd.execute();

    String output = cmd.getStdOut();
    if (!cmd.isSuccessful()) {
      throw new WindowsRegistryException("exec return code " + cmd.getExitCode() + ": " + output);
    }
    return output;
  }
Exemplo n.º 2
0
 /* Execute scutil and quit, returning the output */
 protected String runScutil(String arg) {
   CommandLine command = new CommandLine(findScutilBin());
   command.setInput(arg + "\nquit\n");
   command.execute();
   String output = command.getStdOut();
   if (!command.isSuccessful()) {
     throw new RuntimeException("exec return code " + command.getExitCode() + ": " + output);
   }
   return output;
 }