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 FilesJavaThingyJava.exe -silent -otherParameters:”value” -finalParameter

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

“C:Program FilesJavaThingyJava.exe” -silent -otherParameters:”value” -finalParameter

Then, double all quotes in the whole line

“”C:Program FilesJavaThingyJava.exe”” -silent -otherParameters:””value”” -finalParameter

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

WshShell.Run “””C:Program FilesJavaThingyJava.exe”” -silent -otherParameters:””value”” -finalParameter”, 1

Be Sociable, Share!
This entry was posted in VBScript. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *