• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Get a cmd prompt @ a particular dir. location.

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me ask this Q with an example:
I run my Class A from d:\product\scripts. In A I want to do a Runtime.getRuntime().exec("a.bat"); a.bat is in d:\product. So is there a way I can specify the dir. location of the Process that I get by doing a Runtime.getRuntime() - in this case as d:\product - meaning run a.bat @ d:\product.
Interestingly, I expected that there'll be an overloaded exec(), which let's me specify the dir. location.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know of any way to make exec use a specific directory. Why not just put the necessary drive and cd commands in the batch file, thats what I do.
Bill
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vishal Saxena:

Interestingly, I expected that there'll be an overloaded exec(), which let's me specify the dir. location.


Check the documentation for java.lang.Runtime There are two versions of exec() which accept the working directory as an argument.
 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not just do this:
Runtime.getRuntime().exec("d:\\product\\a.bat")

Brian
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic