How Can I Execute an External Program from a DIAdem Script?

Updated Jul 31, 2018

Reported In

Software

  • DIAdem

Programming Language

  • Visual Basic .NET

Issue Details

I am developing a script in Diadem 2017. I want to execute an external application from it, how can I do this?

Solution

You can execute any application or command using Windows' Scripting Host's shell method.

The following snipped shows its usage by executing Windows' text editor Notepad:
Option Explicit
dim myShell
set myShell= CreateObject("WScript.Shell")
myShell.run("notepad")


Additional Information

In the solution above the external application called will run asynchronously. DIAdem/the script will not wait for the called application to finish before executing the next line(s). To make DIAdem wait for the application to finish, use additional parameters with the Shell.Run command:
Option Explicit
dim myShell
set myShell= CreateObject("WScript.Shell")
myShell.run("notepad"), 1, true
myShell.popup("This command is executed only after notepad was closed")


Note: The second, numeric parameter controls the appearance of the started application's window, in case it supports this parameter. See the table in the Remarks section of Run Method's documentation for more information about possible values.

If you need access to return values or outputs of the external program, use the Exec Method instead: Accessing the Output of an External Command Executed in a DIAdem Script

WAS THIS ARTICLE HELPFUL?

Not Helpful