• Post Reply Bookmark Topic Watch Topic
  • New Topic

Runtime.exec  RSS feed

 
shivani vidit
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to execute a batch file which requires command prompt path to be changed since some files used in batch are on that location. The code i am wriiting is"

String ar[]=new String[5];
ar[0]="cmd.exe";
ar[1]="/c";
ar[2]="start";
ar[3]="cd /d c:\\capitec\\tallyman operations\\bin\\";
ar[4]="process.bat";
Process pro=Runtime.getRuntime().exec(ar);

now the problem is, since there is a space in the name of "tallyman operations" folder therfore it's taking path from"operations\\bin\\".

i tested it by removing the space from the folder name, then it ie running fine.
but in actual enviorment i can change the folder name , please suggest what should be done so that it will take the entire path and change dir to "c:\captic\tallyman operations\bin.

it's very urgent... please help
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivani vidit wrote:
it's very urgent... please help

http://faq.javaranch.com/java/EaseUp

Try putting tallyman operations in quotes, like "tallyman operations"
 
shivani vidit
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reptying...but the entire path is already inside ""
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

ar[3]="cd /d \"c:\\capitec\\tallyman operations\\bin\\\"";

Also a must read about Runtime.exec: here.
 
shivani vidit
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks...that issue has been resolved...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!