java cannot call bat file

R

rynox

hi all ,

i have a problem . i am trying to call a bat file from java. When i
test using a exe file. I can call the exe file, but when its a .bat. it
just doesnt seem to work. here is the code:-

File[] fdrives = File.listRoots();
Runtime run = Runtime.getRuntime();
try {
frame.dispose();
JOptionPane.showMessageDialog(null,"Start Installation");
Process
pp=run.exec("D:\\EAServer_v4_Developer\\SilentInstall_Win.bat");
JOptionPane.showMessageDialog(null,"Installation Complete");
}
catch (Exception e) {
JOptionPane.showMessageDialog(null,"Error occured");
}

the location of the bat file is correct. Its a silent installation for
EAServer. Does anyone have any idea how come this happen ? Please help
or advice.

@ could mail me at (e-mail address removed) also. :)

Thanks.

marvin.
 
I

Ingo R. Homann

Hi,
pp=run.exec("D:\\EAServer_v4_Developer\\SilentInstall_Win.bat");

A Batch-file is nothing that is "executable". But the shell is able to
read and interpret it (that's what happens when you double-click on it -
so it *seems* as if it were executable). That is similar to what happens
when you double-click on any other file: The fact that double-clicking
on a ".doc"-file causes Word to start and to open the file does not mean
that ".doc"-files are "executable".

That is the long answer. The short one is: Try something like the following:

pp=run.exec("cmd.com /c D:\\EAServer_v4_Developer\\SilentInstall_Win.bat");

Hth,
Ingo
 
J

Jeff Kish

Hi,


A Batch-file is nothing that is "executable". But the shell is able to
read and interpret it (that's what happens when you double-click on it -
so it *seems* as if it were executable). That is similar to what happens
when you double-click on any other file: The fact that double-clicking
on a ".doc"-file causes Word to start and to open the file does not mean
that ".doc"-files are "executable".

That is the long answer. The short one is: Try something like the following:

pp=run.exec("cmd.com /c D:\\EAServer_v4_Developer\\SilentInstall_Win.bat");

Hth,
Ingo
fyi.. I think 'cmd.exe' might be usable, but not 'cmd.com' as I don't think
that always exists... probably windows version dependant.
Jeff Kish
 
R

rynox

hi ingo,

i have tried this the line u told me > >
pp=run.exec("D:\\EAServer_v4_Developer\\SilentInstall_Win.bat"); but it
seems that i get an error when i execute it. is there any other java
classes that is able to run .bat files.

thanks.
 
R

rynox

hi guys

i tried this :
String line = "cmd.com /c
D:\\EAServer_v4_Developer\\SilentInstall_Win.bat";
Process pp=run.exec(line);
but now i face error 2 when it loads that line. ive seen many forums
also that state this is the line to call batch files but it just
doesnt work. am i missing some parameters there ? please advice.

thanks.
 
J

Jeff Kish

hi guys

i tried this :
String line = "cmd.com /c
D:\\EAServer_v4_Developer\\SilentInstall_Win.bat";
Process pp=run.exec(line);
but now i face error 2 when it loads that line. ive seen many forums
also that state this is the line to call batch files but it just
doesnt work. am i missing some parameters there ? please advice.

thanks.


rynox wrote:
<snip>
Try cmd.exe instead of cmd.com.
Look on your system in your windows directory and see if you have a cmd.com..
you probably don't.
See if you have cmd.exe? you probably do.
Regards, and HTH
Jeff Kish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top