Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

java cannot call bat file

Thread view: 
rynox - 13 Jul 2006 09:48 GMT
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 marvin606@yahoo.com also. :)

Thanks.

marvin.
Ingo R. Homann - 13 Jul 2006 10:02 GMT
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
Jeff Kish - 13 Jul 2006 15:05 GMT
>Hi,
>
[quoted text clipped - 13 lines]
>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 - 14 Jul 2006 02:16 GMT
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.

> Hi,
>
[quoted text clipped - 13 lines]
> Hth,
> Ingo
rynox - 14 Jul 2006 04:25 GMT
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.

> hi ingo,
>
[quoted text clipped - 22 lines]
> > Hth,
> > Ingo
Jeff Kish - 14 Jul 2006 14:08 GMT
>hi guys
>
[quoted text clipped - 7 lines]
>
>thanks.

<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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.