Friday, June 19, 2015

VBscript to invoke application

credit: http://www.learnqtp.com/ways-to-launch-your-application/



  1. Create a “WScript.shell” object.
  2. Use the “run” object to launch the application. If the path to your executable contains spaces, use Chr(34) to ensure the path is contained within double quotes.
  3. When done, set the shell object to nothing to release it.
Example:
  1. Dim oShellSet oShell = CreateObject ("Wscript.shell")'
  2. 'Example 1 - run a batch file:
  3. oShell.run "F://jdk1.3.1/demo/jfc/SwingSet2.bat"
  4. 'Example 2 - run a Java jar file:
  5. oShell.run "java -jar F://jdk1.3.1/demo/jfc/SwingSet2/SwingSet2.jar"
  6. 'Example 3 - launch Internet Explorer:
  7. oShell.Run Chr(34) & "C://Program Files/Internet Explorer/IEXPLORE.EXE" & Chr(34)
  8. Set oShell = Nothing