I have the following code to open a command prompt window Runtime.getRuntime().exec("cmd.exe /c start");, but I'm trying to open the prompt with a different location loaded into it.
The idea behind the program is to allow the user to choose one of 3 options to load the command prompt window into, and they're mounted on different locations for example two of them are X:/myJava/ and H:/publicJava/.
How can I open the command prompt window that is loaded into these folders once the user makes their choice?
3 Answers 3
Use this Runtime.getRuntime().exec("cmd.exe /c start", null, new File("X:/myJava"));
2 Comments
You can use making a batch file with commands like
x:
cd publicJava
and then execute that batch file using the Runtime.getRuntime().exec("myBatch.bat");
Comments
Try this
Runtime.getRuntime().exec("cmd.exe /c start /d d:\\java");
The start command accepts a path via the "/d" switch. Keep in mind that you have to escape the backwards slash in the path, hence the double slash.
2 Comments
Runtime.getRuntime().exec("cmd.exe /c start", null, new File("X:/myJava"));