Problem Starting Application Using VBScript?

Today, someone asked me about a problem he had running an application from VBScript. Here is the text of my reply:

Adding the parameters to the end of the .exe name should work. Often, however, the problem is spaces / quotes in the command line. The following recipe should deal with all such problems.

Write out the command you want to execute in full, e.g.
 C:\Program Files\JavaThingy\Java.exe -silent -otherParameters:”value” -finalParameter

If there is a space in the path to the executable, put this bit in quotes.

“C:\Program Files\JavaThingy\Java.exe” -silent -otherParameters:”value” -finalParameter

Then, double _all_ quotes in the whole line

“”C:\Program Files\JavaThingy\Java.exe”” -silent -otherParameters:””value”” -finalParameter

Put another set of quotes around the whole thing, and add the WshShell.Run gubbins:

WshShell.Run “””C:\Program Files\JavaThingy\Java.exe”” -silent -otherParameters:””value”” -finalParameter”, 1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: