You can use the RunCommand statement in a QA Wizard Pro script to launch a DOS command from the Windows command line. The information required for a RunCommand statement includes:

  • Executable path
  • Working directory
  • Command line arguments


The executable is cmd.exe, which is located in C:\WINDOWS\system32\.

The working directory can be any location you choose.

The command line arguments is a string containing the command you wish to execute and any needed parameters or flags.

When creating the argument string:

  • You must enclose the DOS command and arguments in quotes, using the escape character (i.e., \”dir *.doc \”)
  • You must escape the backslash character in any path specification (i.e., “C:\\WINDOWS\\system32\\cmd.exe”)
  • You must use the ‘/C’ flag to force the command window to close upon completion
  • You must enclose the entire command line argument string in quotes (i.e., “/C\”dir *.doc \”")

For example, the following script step will copy file1.txt to file2.txt in the C:\Output directory:

          RunCommand("C:\\WINDOWS\\system32\\cmd.exe", "C:\\Output", "/C\"copy file1.txt file2.txt\"")

The working directory will be used for redirection unless otherwise specified in the command line arguments.

This will list the contents of the C:\Test directory in the file C:\My Files\list.txt:

          RunCommand("C:\\WINDOWS\\system32\\cmd.exe", "C:\\Output", "/C\"dir C:\\Test > C:\\My Files\\list.txt\"")

Since the RunCommand statement returns ’0′ if successful or ’1′ otherwise, you can branch on the result of the statement:

          If RunCommand("C:\\WINDOWS\\system32\\cmd.exe", "", "/C\"dir > C:\\data.txt\"") = 1 Then
              Println("File not found!")
          End If
Share on Technorati . del.icio.us . Digg . Reddit . Slashdot . Facebook . StumbleUpon

Related posts:

  1. Executing DOS Commands from a QA Wizard Pro Script
  2. Preventing Batch Files from Stopping Due to Individual Script Failure
  3. Think Outside the Window
  4. Running Executables from TestTrack Automation Rules
  5. Emailing Test Results
1 Comment

Tags: , ,

1 Comment to Running DOS Commands from a QA Wizard Pro Script

[...] Running DOS Commands from the Command Line [...]

Leave a comment

WP_Big_City

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree

Page optimized by WP Minify WordPress Plugin