Executing .cmd with Runtime.exec()

I'm trying to run a file with the following cod:

Runtime rt = Runtime.getRuntime();

String[] command ={"cmd.exe","/c","start","c:\\Documents and Settings\\Rahul Shroff\\Desktop\\svn\\trunk\\c\\rahul_facedetect.cmd"};

try{

Process proc = rt.exec(command);

}

catch(Exception e){System.out.println("error with proc" + e.getMessage());}

With the code, a command prompt is opened, but my .cmd file is not. Does anyone know how to fix this? Please don't send me a link to the "When Runtime.exe() Won't" ; I have already looked through this. Thanks!

[947 byte] By [wrdstomakeupa] at [2007-10-3 2:46:53]
# 1

So I read some more threads about Runtime.exec() usage, and I found that it is not possible to exec a .cmd file. I replaced my String[] command as follows:

String[] command = {"cmd.exe", "/c", "start", "rahul_facedetect.exe --cascade=C:\\Documents and Settings\\Rahul Shroff\\Desktop\\svn\\trunk\\OpenCV\\data\\haarcascades\\haarcascade_frontalface_alt.xml"};

and I get the same error.

wrdstomakeupa at 2007-7-14 20:35:39 > top of Java-index,Java Essentials,Java Programming...
# 2
Did you try to do a forum search?How many Runtime threads have their been in the last 2 days alone?You could always start a batch file and have the batch file do allthe work.
TuringPesta at 2007-7-14 20:35:39 > top of Java-index,Java Essentials,Java Programming...
# 3
I did do a forum search and read about 20 threads, but most of them had to do with people forgetting to use "cmd.exe /c". The only threads I could find with people who had the same problem as me were never resolved.
wrdstomakeupa at 2007-7-14 20:35:39 > top of Java-index,Java Essentials,Java Programming...
# 4
Get out of your Java IDE and open a command line. Fiddle about with the command line until you find something that works. (Using spaces in your directory name is going to make this a slow process.) Then go back into your Java IDE and write the code to exec(something that works).
DrClapa at 2007-7-14 20:35:39 > top of Java-index,Java Essentials,Java Programming...
# 5

Okay, I tried that, and the code compiled fine, but I got this runtime error:

error with procCreateProcess: "C:\Documents and Settings..." error = 123

My code is :

Runtime rt = Runtime.getRuntime();

String[] command = {"C:\\Documents and Settings\\Rahul Shroff\\Desktop\\svn\\trunk\\c\\rahul_facedetect.exe --cascade=C:\\Documents and Settings\\Rahul Shroff\\Desktop\\svn\\trunk\\OpenCV\\data\\haarcascades\\haarcascade_frontalface_alt.xml"};

try{

Process proc = rt.exec(command);

System.out.println("tried to execute .cmd");

}

catch(Exception e) {System.out.println("error with proc" + e.getMessage());}

}

I am sure that the command C:\Documents and Settings... works; I've tried it separately in a command prompt. Any suggestions? Thanks for the help!

wrdstomakeupa at 2007-7-14 20:35:39 > top of Java-index,Java Essentials,Java Programming...
# 6
UUUUSE AAAA BAAATTTCCCHH FIIIIILLLEEEE.Is this command ever changing?You can even pass parameters to a batch file.
TuringPesta at 2007-7-14 20:35:39 > top of Java-index,Java Essentials,Java Programming...
# 7

I've never created a batch file, but I made this simple batch file and it does not work. When I run it, it simply opens up a command prompt instead of opening the program. Could you tell me what I'm doing wrong? Thanks!

start "C:\\Documents and Settings\\Rahul Shroff\\Desktop\\svn\\trunk\\c\\rahul_facedetect.exe --cascade=C:\\Documents and Settings\\Rahul Shroff\\Desktop\\svn\\trunk\\OpenCV\\data\\haarcascades\\haarcascade_frontalface_alt.xml"

wrdstomakeupa at 2007-7-14 20:35:39 > top of Java-index,Java Essentials,Java Programming...
# 8

yea you quoted the whole thing.

also try to use some style.

put some pride into making a kick @ss lame batch file

@ECHO OFF

REM ********************

REM * Created by: ME

REM * Created on:

REM ********************

TITLE Run My Program!

set %PATH%="C:\\Documents and Settings\\Rahul Shroff\\Desktop\\svn\\trunk\\c\\"

set %PARM1%=--cascade="C:\\Documents and Settings\\Rahul Shroff\\Desktop\\svn\\trunk\\OpenCV\\data\\haarcascades\\haarcascade_frontalface_alt.xml"

@ECHO ON

start %PATH%\rahul_facedetect.exe %PARM1%

--

I dont know if my sets are right but spice it up. Keep it fun.

TuringPesta at 2007-7-14 20:35:39 > top of Java-index,Java Essentials,Java Programming...