ShellAPI

You can use the ShellAPI function in Optiva workflows to perform an action for a registered application, such as opening a file or displaying a URL in a browser.

This function can launch external applications, open files, or display URLs by executing shell commands. It can also open documents in their associated applications or navigate to web addresses.

When to use

You can use this function to:

  • Launch web reports or Crystal Reports in a browser or viewer.
  • Open PDF, Word, and Excel files in their associated applications.
  • Direct users to web pages, help documentation, or online resources.
  • Execute external programs or tools from within workflows.
  • Display files with registered handlers.

When not to use

You cannot use this function with user provided paths that have not been validated because they can introduce security risks.

Syntax

int ShellAPI(string TgtName);

Parameters

Parameter Type Required Description
TgtName string Yes Path to the file or URL. If the target is an executable, parameters are passed to the executable.
Note: The parameters vary according to the program.

Return Value

The application returns a value >0 if the operation is successful.

Impact

  • Validate file paths before using.
  • Use whitelist of allowed paths/domains.

Prerequisites

  • Local files must exist at specified path.
  • File type must have associated application registered.
  • Subject to system security policies.

Examples

Example 1
Open URL in Browser.
int iOpen = ShellAPI("http://www.yahoo.com");
Description
This example determines to open the Yahoo home page.
Example 2
Open Microsoft Word Document.
ShellAPI("C:\\Database Files\\DBChanges.doc");
Description
This example opens a Microsoft Word file. Open is the default action and no other action is specified.