Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Execute linux command as superuser by default [closed]
- Runtime.getRuntime().exec("su")
- public void runCommandsAsRoot(String[] cmds) throws IOException {
- Process proc = Runtime.getRuntime().exec("su");
- DataOutputStream oStream = new DataOutputStream(proc.getOutputStream());
- for (String cmd : cmds) {
- oStream.writeBytes(cmd + "n");
- }
- oStream.writeBytes("exitn");
- oStream.flush();
- }
- String[] commands = { "fistCommand", "secondCommand" };
- runCommandsAsRoot(commands);
Add Comment
Please, Sign In to add comment