Example Code

Passing Custom Command Line Arguments to a TestStand Operator Interface (CVI)

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.


  • Teststand

Code and Documents




The TestStand Application Manager supports processing custom command line arguments through the ProcessUserCommandLineArguments event. This can prove useful when automating test execution from a CI server.



This example is similar to the LabWindows/CVI Basic User Interface, but has been modified to accept the following command line arguments:

Option Purpose
/SimulateFailure <failures> When used with the included example sequence file, this suppresses the simulation dialog and instead simulate failures as specified. This argument accepts the following parameters:
  • Keyboard
  • Video
  • Power
  • CPU
  • ROM
  • RAM
If no parameters are specified, then all components are simulated to pass.


This example demonstrates the following concepts:

  • Using TSUI__ApplicationMgrEventsRegOnProcessUserCommandLineArguments to handle custom command line arguments
  • Modifying a TestStand user interface to print UI error messages to the console and set the return code appropriately
  • Use of the TSUI_ApplicationMgrAddCommandLineArgumentsHelp function to add custom command line arguments help.
  • Creating a custom UI Message handler to pass command line data to sequence execution.

Note: By default, TestStand shows dialogs under certain conditions. This can cause hangs when automating sequence execution without user input, such as when ran from a CI Server. In order to prevent popups that require user input, configure the following options:

  • Disable User Management or automatically log in the System User
  • Set the 'Station Options » Execution »  On Run-Time Error' setting to something other than 'Show Dialog', such as 'Run Cleanup'.
  • Specify 'Station Options » Time Limits' for Exiting and Normal Execution such that the user will not be prompted.
  • Pass the /quit argument via the command line so TestStand automatically shuts down after all executions are complete.

Hardware and Software Requirements

TestStand 2014 SP1 or later

LabWindows/CVI 2015 or later

Steps to Implement or Execute Code

  1. Unzip the attached code, open the .cws, and build the project for the bitness of TestStand you have.
  2. Open a command window in the <ExampleDir>\ModifiedBasicOI_CVI directory (Shift + Right Click » Open command window here).
  3. In order to see the Command Line help, run:

    TestExec /?

  4. Experiment with the /SimulateFailure argument. For example:

    TestExec /runEntryPoint "Single Pass" "<ExampleDir>\TestSequence\Computer Motherboard Test Sequence.seq" /SimulateFailure Keyboard Video RAM /quit


Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.