Runtime.getRuntime().exec() append the parameters

B

balaguruthangaraj

String[] command = new String[] {"CSCRIPT", vbsFile , "arg1" ,
"arg2"};
Runtime.getRuntime().exec(command);

and

Runtime.getRuntime().exec("CSCRIPT vbsfile arg1 arg2");

In the above code arg1 and arg2 are append when I got these arguments
in vbsfile.
But When I excute the same in command prompt it works fine.
Is anybody face this issue?
 
J

John B. Matthews

String[] command = new String[]
{"CSCRIPT", vbsFile , "arg1" , "arg2"};
Runtime.getRuntime().exec(command);

and

Runtime.getRuntime().exec("CSCRIPT vbsfile arg1 arg2");

In the above code arg1 and arg2 are append when I got these arguments
in vbsfile.

I don't understand what difference you are seeing. Can you paste a
verbatim transcript of your results? Is your OS case sensitive? [vbsFile
versus vbsfile]
But When I excute the same in command prompt it works fine.
Is anybody face this issue?

Are your actual arguments correctly quoted so that they may be "broken
into tokens using a StringTokenizer," as discussed here:

<http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html>
 
L

Lothar Kimmeringer

In the above code arg1 and arg2 are append when I got these arguments
in vbsfile.
But When I excute the same in command prompt it works fine.
Is anybody face this issue?

What exactly are the values of arg1 and arg2. If they contain
wildcards or other things that are interpreted by the command-
interpreter working in a command shell, you have to call that
command-interpreter from Java instead of calling cscript.

Also you might make sure that cscript and/or your Visual Basic
file are not relying on environment variables that are not set
within your Java-process.

This is all I can tell without knowing more about the calling
parameters and error-messages that are returned from the
called process.


Regards, Lothar
--
Lothar Kimmeringer E-Mail: (e-mail address removed)
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!
 
B

balaguruthangaraj

Hi,

There was no error message on this.
The vbs script was executed , so no necessary to set environment
variables for this.
arg1 and arg2 have no wildcards just alphabet only.
Note that It does not happen at all time.Some time it succeed some
time the parameters appends.

Machine details:

Processor: Intel Xeon Cpu E5420 @2.50Ghz
OS: Windows Server 2003 Standard SP2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top