• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • 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: 22743
129
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...
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic