This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Get a cmd prompt @ a particular dir. location.

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
  • 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: 9582
13
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Why not just do this:
Runtime.getRuntime().exec("d:\\product\\a.bat")

Brian
 
And inside of my fortune cookie was this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!