I have created a OpenNotepad.bat file with text stating "C:\windows\system32" notepad.exe
and saved it to my desktop. I have created a Java class. What do I have to type in the cmd to get that text from the .bat file?
Is there a specific command that I should use to get the command prompt to display that text?
Here is my Java code:
public class OpenBatchFile {
public OpenBatchFile() {
super();
}
public static void main(String[] args) {
//Get Runtime object
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("cmd /c start Desktop:\\OpenNotePad.bat");
}
catch (IOException e) {
System.out.println(e);
}
}
}
I am totally new to this. I referred to this tutorial: Execute batch file from Java Code using Runtime class