By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,961 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,961 IT Pros & Developers. It's quick & easy.

Problems W/ VBScript (Yes -- I use "start"!)

P: n/a
I know that I need to launch a VBS file on Windows this way:

Win9x:
Runtime.getRuntime().exec("start script.vbs");

WinNT:
Runtime.getRuntime().exec("cmd /c start script.vbs");
I'm doing this, and verifying what the command line looks like before I try
to run it. I am not getting any VBS files to run. That leads to a few
more questions:

1) Even though the scripts aren't running, console windows are popping open.
Is this supposed to happen (I get a prompt, but nothing else in the
window)? Could it be an indication of what is wrong?

2) Does running a VBS file from Java always open a console window? Is there
a recommended way to avoid it? If I redirect output to a tmp file
somewhere, will that cause any damage? (Is there anything like /dev/null
for Windows?)

3) Does XP use a different command than the ones listed above (I couldn't
find it)? I'd expect it to be like WinNT and that's what I'm using.

4) I've found that when I run Windows programs fromm Java, if there are
spaces in the filenames (which happens often if it's in "Program Files"), I
have to put quotations around the command name. Does this have any effect
on running VBS files? It doesn't seem to effect .bat files and seems
required for them (if there's a space in the filename).

Thanks for any help on this. I'd post code, but it's several routines, one
to create a filename from other program info, and one to run the program
(which uses a line like the ones above).

Hal
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hal Vaughan wrote:

3) Does XP use a different command than the ones listed above (I couldn't
find it)? I'd expect it to be like WinNT and that's what I'm using.


Windows guarrantees that the command interpreter executable will always
be defined in the %COMSPEC% environment variable.

Ray
Jul 17 '05 #2

P: n/a
Raymond DeCampo wrote:
Hal Vaughan wrote:

3) Does XP use a different command than the ones listed above (I couldn't
find it)? I'd expect it to be like WinNT and that's what I'm using.


Windows guarrantees that the command interpreter executable will always
be defined in the %COMSPEC% environment variable.

Ray


Thanks! This helped answer ALL the questions. Until I saw this and changed
my program around, I didn't realize I was dealing with a deep "nesting"
that was probably making the normal execution path unavailable (I ran a VB
script that called a batch file that called a Java program, that later
called a batch script, which, in turn called a Java program that ran the
final VB script).

I changed my system so when it is installed, it reads %COMSPEC% and puts it
into a config file, then uses it whenever it needs to run a VBScript
program. It works and makes all the other questions I had moot.

Thanks for one small piece of VERY helpful info!

Hal
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.