Create a Text or Batch File in TestStand

Updated Dec 18, 2017

Reported In

Software

  • TestStand

Issue Details

I'd like to create a text file or batch file programmatically as TestStand runs, but I can't find any features to accomplish this.

Solution

Although TestStand does not support building text files or batch files programmatically, we can use TestStand and the Windows command line to accomplish the same task. Complete the following steps to create a text or batch file in TestStand:

  1. Create a new Call Executable step in a TestStand sequence to call the Windows Command Prompt executable, usually located at <Windows>\System32\cmd.exe.
  2. Create a folder in which you wish to create your text or batch file as the command prompt cannot always create files in your root directory or in certain system directories.
  3. Modify the Argument Expression under the Call Settings tab to contain the following command: " /C echo yourtext >> C:\\yourfolder\\textfile.txt "
  4. In order to write to a batch file, simply change .txt to .bat in the above command.

Note: The /C parameter instructs the command prompt to execute the command which follows before terminating. This command is necessary to use this technique. The double slashes in the command's file path are escape characters required by TestStand.

Please refer to below figure for a sample command illustrating this process. This step will write the word test into a file named test.txt located at C:\test\test.txt.

Additional Information

WAS THIS ARTICLE HELPFUL?

Not Helpful