Re: Executing vbscript
lionelv@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?
You might try using the new Desktop class. I've found that it is a
great improvement over Runtime.exec() for many things. It is also more
portable.
--
Knute Johnson
email s/nospam/knute/