Re: Executing vbscript
On Aug 22, 9:11 am, "lion...@gmail.com" <lion...@gmail.com> wrote:
On Aug 22, 5:18 am, Alexey <inline_f...@yahoo.com> wrote:
On Aug 21, 2:47 am, "lion...@gmail.com" <lion...@gmail.com> wrote:
Hi all,
I have a vbscript that I would like to execute from java. It takes 4
arguments, and example usage follows:
"C:\cvs_checkout\tool\Projects\UserInterface\utils
\ReplaceWorksheets.vbs" "C:\Documents and Settings\vandenbergl\Desktop
\sheet.xml" "Sheet 1,Sheet 2" "C:\Documents and Settings\vandenbergl
\Desktop\Test\another sheet.xml" "sheet 1,sheet 2"
Here is the code that I'm using at the moment:
String[] command = {"cmd.exe", argument};
try {
Process mergeProcess = Runtime.getRuntime().exec(command);} catch (IOException ioe) {
ioe.printStackTrace();
}
Where argument is the expression I gave above.
If I executre the expression I gave at a prompt it does exactly what I
want, but the java code I gave doesn't do anything at all. It doesn't
throw any exceptions but it appears the script hasn't even run!
Any ideas about how I can get the script to run?
Be sure you're reading everything the process object writes into its
streams.
I did as you said (good point btw) but I get the following
uninteresting output:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
and then the input stream blocks indefinitely.
Should probably have included:
Process process = Runtime.getRuntime().exec(command);
BufferedReader streamReader = new BufferedReader(
new InputStreamReader(process.getErrorStream()));
String line;
while ((line = streamReader.readLine()) != null) {
System.out.println(line);
}
I did the above for both input stream and error stream. error stream
gives nothing!