Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String filepath = "D:";
- String filename = "hello.bat";
- try {
- ProcessBuilder p = new ProcessBuilder();
- p.directory(new File(filepath));
- p.command("cmd.exe", "/c ", filename);
- Process process = p.start();
- process.waitFor();
- InputStream in = process.getInputStream();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- int c = -1;
- while((c = in.read()) != -1)
- {
- baos.write(c);
- }
- String response = new String(baos.toByteArray());
- System.out.println("Response From Exe : "+response);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement