Reputation: 27
This is the code I've been using:
ProcessBuilder process = new ProcessBuilder("C:\\Users\\path\\to\\exe\\my_exe.exe ",
"my_exe.exe", "/removeDrive", "driveLocation");
process.start();
All this seems to do is run the exe, but I can't get it to run the command I want.
The command in CMD would be:
C:\users\path\to\exe>my_exe.exe /removeDrive driveLocation
The command works fine in windows Command Prompt
Upvotes: 0
Views: 5214
Reputation:
Another way to do the same thing:
ProcessBuilder pb = new ProcessBuilder(
"cmd", "/c", "path/to/exe.exe",
"/removeDrive", "driveLocation");
pb.start();
Or if you don't need output:
Runtime.getRuntime().exec("cmd /C my_exe.exe /removeDrive driveLocation");
Upvotes: 2