Running Multiple Commands Sequentially using a Batch File

Author: Optuma Team Last updated: Jan 3, 2019 01:57

Instead of scheduling multiple Windows Tasks that may overlap, use the “start /wait” command a batch file (.bat) to automatically run multiple commands in sequential order.

Creating the Batch file

In Notepad create a new text file with the first two lines as follows (NOTE: the path in the second line is the default installation location - if Optuma has been installed elsewhere eg C:/Optuma then use that).

SETLOCAL
SET PATH=”C:\Program Files\Optuma”

The third line begins with “start /wait Optuma.exe” followed by the command lines (NOTE: to easily build the command line use the Command Line Prompt Builder button).

start /wait Optuma.exe {your optuma print command}

You can then add as many command line prompts as you wish, with each line beginning with the start /wait command. This example will run three commands in sequential order:

  1. A scan to output a .csv file of the new 52 week highs to a Scans folder
  2. Create image files (.png) of the charts in the Tech Weekly workbook (saved to the Desktop)
  3. Create a PowerPoint presentation on the Desktop of the charts in the My Portfolio Symbol List using the DailyWeekly Page Layout

SETLOCAL
SET PATH=”C:\Program Files\Optuma”
start /wait Optuma.exe -csv -scan -sn “52 Week Closing Highs” -out “C:\Users\DH\Scan” -filename “52_Week_HiLo”
start /wait Optuma.exe -png -wb “Tech Weekly.owb” -landscape -out “C:\Users\DH\Desktop”
start /wait Optuma.exe -ppt -sl “My Portfolio” -pl “DailyWeekly” -out “C:\Users\DH\Desktop”

Running the batch file

Once the file his been created in Notepad save the file and change the extension to .bat to make it a recognised batch file:

  • open the Windows File Explorer and click on the View menu
  • tick the the File name extensions box
  • with the file extension visible, right-click on the saved text file and change the .txt extension to .bat to change the file type to a Windows Batch File

Capture.PNG
Once changed, double-click to run the commands, or use it in the Windows Task Scheduler.

IMPORTANT THINGS TO NOTE

  • The limitation with this method is if a command raises an error, it’s likely that all subsequent calls will fail.
  • Optuma needs to be closed for this to work properly (if the program is open then only the last command in the batch file will be run).