This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

exec of batch file fails  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to execute a batch file from my java code and am having trouble getting it to work on Windows CE.
Runtime.getRuntime().exec(mycmd) always throws the exception: java.IOExeception: CreateProcess: mycmd error=2

Testing I found that:
Runtime.getRuntime().exec("/Hard Disk/redit.exe") works, but
Runtime.getRuntime().exec("/Hard Disk/foobar.bat") fails as above.

foobar.bat exists and executes just fine from the command line (it's just a single echo statement).

Anyone know how I can get java/WinCE to cooperate?

* machine: LC7000 (X86 architecture)
* OS: WinCE 5.0
* jvm: CrE-ME V4.12 (Evaluation version)

Thanks!
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might help

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
 
Allan Sorenson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THANK YOU, Prateek!

Toward the end of the article was the solution I needed. Specifically:
Runtime.getRuntime().exec("/windows/cmd.exe /C \"/Hard Disk/foobar.bat\"");

I had tried a similar suggestion from else where, but it involved creating the cmd.exe proc and sending it the desired command via a stream. The creation of the cmd.exe proc however, caused the interactive session to begin. The above simply executed the batch file.
 
Aum Tao
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome, Allan.

I suspected that solution but I thought you would understand it better with concrete examples.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!