This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes problem in running  dos command  from  java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem in running  dos command  from  java" Watch "problem in running  dos command  from  java" New topic
Author

problem in running dos command from java

aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
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


Regards<br />Aminur
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Try
Runtime.getRuntime().exec("cmd /K start myb.bat");


"JavaRanch, where the deer and the Certified play" - David O'Meara
aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
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
 
 
subject: problem in running dos command from java
 
Similar Threads
Launching a DOS batch file
FileNotFoundException but Why?
What is wrong with my Eclipse3.3.1 Setting??
how to read value from console ??
Runtime.exec( ) is hanging....