Ok, so I’ve been looking around for a while, and I can’t figure out what’s wrong with my program. I’m trying to make a cmd.exe like program. One command is supposed to launch msconfig.exe, located in C:/Windows/System32. But it gives me a java.io.IOException:
java.io.IOException: Cannot run program "C:/Windows/System32/msconfig.exe": CreateProcess error=2, The system cannot find the file specified
Here’s my code:
public static void msconfig() {
try {
Runtime rt = Runtime.getRuntime();
Process process = rt.exec("C:/Windows/System32/msconfig.exe");
InputStream in = process.getInputStream();
OutputStream out = process.getOutputStream();
InputStream err = process.getErrorStream();
} catch (IOException e) {
Console.printToConsole("Could not launch msconfig.exe");
e.printStackTrace();
} finally {
Console.printToConsole("Successfuly launched msconfig.exe");
}
}
EDIT:
So I exported the application with Eclipse and now it works fine! Thank you everybody who tried to help me 🙂
The path on a Windows computer uses backslashes as a separator. Use:
Just for the sake of completeness, the backslashes need to be doubled because they are the escape character and need to be escaped themselves.