• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem starting .bat file from java code on windows 2003

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to start some bat file from java code. On almost the same server (windows 2003 64 bit) which is STAGING environment, everything works fine, but on the Production environment, bat file is simple not started. Anybody has any idea (running out of it)?

Here is the code:


try {
log.info("Calling external command: ");
Process proc = Runtime.getRuntime().exec("cmd /C start D:\\start.bat");
proc.waitFor();
} catch (Exception e) {
log.error("Error:", e);
}

No exception is thrown.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Search for and read the Javaworld article "When Runtime.exec() won't". It will explain why Process.waitFor can (and often will) block.
I had a problem once with an external process blocking, and after reading this article the problem was solved in minutes.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It looks like the process did not complete yet?!
Perhaps you'll find an answer here.

Otherwise, you should also share with us the content of batch file ...


Regards,
Rok
 
Ivica Boskovic
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is executed, since when I put something like
log.info("...");

at the end, it is executed. I saw cmd in the list of windows processes.

It is always the same, no metter of the content of the bat file,
for example xcopy....

on staging environment works, on production no...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic