run a .bat file in the jar file
Hi,
In my java class I can open a notepad like this :
Runtime rt=Runtime.getRuntime();
Process process=rt.exec("C:\\WINDOWS\\NOTEPAD.EXE");
and it works, but if I want to run another bat fie, It doesn't show any activity, and does not work.
Process process=rt.exec("C:\\test.bat");
Does anyone know how to run a .bat file in the java or jar file?
Thanks.
[405 byte] By [
APTa] at [2007-11-27 6:59:02]

> Hi,
> In my java class I can open a notepad like this :
> Runtime rt=Runtime.getRuntime();
> Process process=rt.exec("C:\\WINDOWS\\NOTEPAD.EXE");
>
> and it works, but if I want to run another bat fie,
> It doesn't show any activity, and does not work.
> Process process=rt.exec("C:\\test.bat");
>
> Does anyone know how to run a .bat file in the java
> or jar file?
> Thanks.
It's working, you're just not seeing it. If you're running it from windows, the "cmd" console will load, execute the bat and then close immediately thereafter. If you would like for the window to stay open, append a "pause" command to the end of the .bat file, or run the jar from the command prompt:
java -jar MyJar.jar
I am running the jar file with the same command line in the cmd, but still is not working, I try to append a pause at the end of the batch file as you said, and let you know the result.
APTa at 2007-7-12 18:49:35 >

> I am running the jar file with the same command line
> in the cmd, but still is not working, I try to
> append a pause at the end of the batch file as you
> said, and let you know the result.
Could you post the source of the .bat file and the line in your class where you're calling the .bat file?