Example of launching a native application

The following example launches a native application, waits for it to terminate, and then displays the return code from the application in a message window. This example uses the following action elements: Run program action, Message action.

You can copy the text of this macro script from this document into the system clipboard, and then from the system clipboard into the Code Editor (see Copy and paste a script from this guide into the Code Editor). After you save this script in the Macro Editor, you can edit it either with the Macro Editor or with the Code Editor.

You should notice the following facts about this example:
  • The example consists of one entire macro script named RUN PROGRAM.
  • The following actions occur in the <actions> element:
    • The <runprogram> element launches a native application, waits for it to return, and stores the return code into $intReturn$.
    • A message action displays the value in $intReturn$ in a message window.
Figure 1. Sample code RUN PROGRAM
<HAScript name="g1" description=" " timeout="60000" pausetime="300"
            promptall="true" author="" creationdate="" supressclearevents="false"
            usevars="true" ignorepauseforenhancedtn="false"
      <create name="$intReturn$" type="integer" value="0" />
   <screen name="Screen1" entryscreen="true" exitscreen="true" transient="false">
         <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
         <runprogram exe=
                  "%ProgramFiles%\Windows NT\Accessories\wordpad.exe"
                  param="'c:\\tm\\new_file.doc'" wait="true"
                  assignexitvalue="$intReturn$" />
         <message title="" value="'Return value is '+$intReturn$" />
      <nextscreens timeout="0" >