cmd - Open a .Bat Using Java Apllication -
i'm trying open cmd using java + applying code open .jar applications output shown in .bat file. can tell me how it?
this code got,it run excecute file cmd doesnt show.
btntest.addactionlistener(new actionlistener() { public void actionperformed(actionevent arg0) { string bat = "c:"+file.separatorchar+"users"+file.separatorchar+"gebruiker"+file.separatorchar+"appdata"+file.separatorchar+"local"+file.separatorchar+"temp"+file.separatorchar+"hext"+file.separatorchar+"run.bat"; runtime rt = runtime.getruntime(); try { rt.exec(bat); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } });
edited: works me:
string bat = "c:\\app.bat"; //try use \\ path seperator try { runtime.getruntime().exec("cmd /c start " + bat); } catch (ioexception e) { e.printstacktrace(); }
Comments
Post a Comment