Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in running dos command from java

 
aminur rashid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i have wriiten a code for running command of DOS-Promt
try
{
rnt1 = Runtime.getRuntime();
proc1= rnt1.exec("myb");//myb is a batch file and proc1 is process class instance
try
{
proc1.waitFor();
}
catch (InterruptedException e)
{
System.out.println("InterruptedException raised: "+e.getMessage());
}

}

catch (IOException ioe)
{
System.out.println("IOException raised: "+ioe.getMessage());
}
But it is giving error while running:
this is showing as an IO exception
CreateProcess: myb error=0
Please help me how to proceed
Thanks

 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try
Runtime.getRuntime().exec("cmd /K start myb.bat");
 
aminur rashid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Cindy Glass:
Try
Runtime.getRuntime().exec("cmd /K start myb.bat");


Thanks but the programme ran by the following command
"start command /K myb.bat"
Thanks again for you valuable answer
Aminur
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic