java cannot call bat file  
Author Message
rynox





PostPosted: 2006-7-13 16:48:00 Top

java-programmer, java cannot call bat file 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 email***@***.com also. :)

Thanks.

marvin.

 
Ingo R. Homann





PostPosted: 2006-7-13 17:03:00 Top

java-programmer >> java cannot call bat file Hi,

rynox wrote:
> 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

 
Jeff Kish





PostPosted: 2006-7-13 22:06:00 Top

java-programmer >> java cannot call bat file On Thu, 13 Jul 2006 11:02:31 +0200, "Ingo R. Homann" <email***@***.com>
wrote:

>Hi,
>
>rynox wrote:
>> 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
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
 
 
rynox





PostPosted: 2006-7-14 9:17:00 Top

java-programmer >> java cannot call bat file 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.

Ingo R. Homann wrote:
> Hi,
>
> rynox wrote:
> > 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

 
 
rynox





PostPosted: 2006-7-14 11:25:00 Top

java-programmer >> java cannot call bat file 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:
> 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.
>
> Ingo R. Homann wrote:
> > Hi,
> >
> > rynox wrote:
> > > 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

 
 
Jeff Kish





PostPosted: 2006-7-14 21:09:00 Top

java-programmer >> java cannot call bat file On 13 Jul 2006 20:25:03 -0700, "rynox" <email***@***.com> wrote:

>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