MetaServer > Help > Run Programs

170 MetaServer Run Programs

With the Run Programs action, you can run one or more windows commands or external programs accepting command line parameters before and after Export.

For example, you can run a batch command file, or an external program performing post-processing of index files.

To add a Run Programs action, select the action after which you want to insert the Run Programs action and press Add -> Run Programs. The Setup window will automatically open.

You can also open the setup window of an existing Run Programs action by double-clicking the action or by pressing the setup button on the right side of the action or in the ribbon, as shown below.

As our example, we will make use of the “CB – CHECKS & INVOICES” workflow. This workflow is automatically installed with CaptureBites MetaServer.

TIP: The thumbnail on the right will follow you, so you can easily refer to the Setup window. Click on the thumbnail to make the image larger.

01 – Add: press the Add button to add a new Run Programs rule.

02 – Edit: press the Edit button or double-click a rule to open its setup window.

03 – Move Up / Move Down: press the Move Up or Move Down button to change the order of the Run Programs rules.

The rules are executed in the sequence of the rules list. Therefore, the order of the rules in the list influences the result.

04 – Delete: press the Delete button to remove the currently selected Run Programs rule.

As a reference, in the “CB – CHECKS & INVOICES” demo workflow, we run the following commands in the Run Programs action:

Rule 1: Move a list of invoices to another folder after being attached to a check using Robocopy.

Robocopy is always included with Windows and is located in:
C:\Windows\System32\Robocopy.exe

Below command moves the invoice PDF files with names in the field { Field, Invoice List Robocopy } to a folder “C:\META-OUT\MFP\CHECKS & INVOICES\MERGED INVOICES\{ Field, Check Nr. }”.

robocopy.exe "C:\META-DEMO\MFP\CHECKS & INVOICES\INVOICES" "C:\META-OUT\MFP\CHECKS & INVOICES\MERGED INVOICES\{ Field, Check Nr. }" { Field, Invoice List Robocopy } /MOV /IS

NOTE: { Field, Invoice List Robocopy } contains a space delimited list of pdf file names.

Rule 2: Add all processed PDFs to a zip file per day using PowerShell.

PowerShell is always included with Windows and is located in:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

powershell.exe Compress-Archive -Path 'C:\META-OUT\MFP\CHECKS & INVOICES\{ Field, Check Nr. }.PDF' -DestinationPath 'C:\META-OUT\MFP\CHECKS & INVOICES\{ Export Date, YYYYMMDD }.ZIP' -Update

Rule 3 (disabled): Print a PDF document after processing it with MetaServer using PDFtoPrinter.exe.

PDFtoPrinter.exe "{ Export File Full Path and Name }"

We will be looking at the 2nd Run Programs rule as an example.

First, add a description to your rule.

01 – Program: specify the path where the program is located. In this case, you want to run Powershell. This is located in:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

02 – Arguments: enter the command line argument for your program. In this case, you want to add all processed PDFs to a ZIP file each day. The argument for this is:

Compress-Archive -Path 'C:\META-OUT\MFP\CHECKS & INVOICES\{ Field, Check Nr. }.PDF' -DestinationPath 'C:\META-OUT\MFP\CHECKS & INVOICES\{ Export Date, YYYYMMDD }.ZIP' -Update

03 – Start in: by default, this will specify the working path based on your selected program. You can also manually change this to another working path you want to use in your argument.

You can easily test your command by entering test values in the Test Values window and pressing the Test button in your Run Programs rule setup window.

01 – Test Values: enter test values in your workflow fields that will be used during your test.

System values like { Export Date, YYYYMMDD } are auto-populated with test values during your test.

02 – Test: after specifying your test values, press the Test button to test your command.

TIP: you can copy the current settings and paste them in another setup window of the same type. Do this by pressing the Settings button in the bottom left of the Setup window and by selecting Copy. Then open another setup window of the same type and select Paste.