Setting up executable files
TaskMan can also be used to execute a command string as an operating system command shell. TaskMan takes the executable name from a Background Task Definitions record, appends the parameters from the form, and attempts to execute the line.
This example shows the steps to set up an executable that runs through TaskMan from a form:
-
Create a file called DeletePreviewFiles.cmd in your TaskMan folder. The text of this
file should look like this:
FOR /D %%D IN ("taskman_dir\Report\OutputFiles\*") DO del /Q "%%D\Preview\*"
where taskman_dir is replaced by the name of your TaskMan folder.
-
Set up a Background Task
Definition record:
- Task Name
- Specify DeletePreviewFiles.
- Executable Name
- Specify DeletePreviewFiles.cmd.
- Executable Type
- Select EXE.
If the executable file is not in the TaskMan folder, include the path to the executable file in the Executable Name field, for example, C:\Program Files\MyExecutable.exe.
-
Add a Button component.
This button will be used to run the executable.
-
In the Component > Properties tab, specify this information:
- Name
- Specify TextEXE.
- Caption
- Specify sTest.
-
Create an event for the TextEXE button:
- In the Component > Events > Primary field, click the ellipses (…) button.
- In the Event Handlers dialog box, click New.
-
In the Event Handler
Properties dialog box, specify this information:
- Event
- Specify RunExe.
- Description
- Optionally, specify the event description.
- Type
- Select Run Background Task.
- In the Parameters field, click the ellipses (…) button.
-
In the Event Handler
Parameters dialog box, specify this information:
- Error Message
- Specify mBackendMessage.
- Success Message
- Specify sSuccess.
- Click Type Specific Parameters.
- In the Edit Background Task Name and Parms dialog box, specify DeletePreviewFiles as the Task Name.
- Click OK.
- Verify that RunExe is the primary event for the TestEXE button.
-
Save the form.
TaskMan will update ActiveBGTasks and BGTaskHistory for EXE tasks. It is up to the executable file to handle all other database connections.