title: Can I use a language other than VBScript to programmatically execute QTP Tests?
body: <p>I have VBScript code which launches QuickTest Professional, executes a series of QTP tests, and emails the results. This works well, but I would prefer to use a language with better tools support (a good IDE for example). I am currently calling .Net libraries from the launch script, so I was wondering if it was possible to use a language like C# to accomplish the same task. If so, are there any good resources which address this? I could find very little on this topic via Google and there do not seem to be any other questions on SO about this topic.</p>
  
  <p>For clarity, I have included the code for the routine that does the bulk of the work. This does not include the .Net declarations, but <code>failedTestsList</code> and <code>allTestsList</code> are instances of <code>System.ArrayList</code>. </p>
  
  <p><strong>EDIT</strong>: All the QTP documentation examples use VBScript, but as you can see, the code is just creating the QTP objects. I would assume these would be callable from another language which supported creation of these objects. It just seems from my Google failures that no one is doing it.</p>
  
  <pre><code>Sub ExecuteQTPTest(name)
      Dim App, resultsPath
      Dim testPath, testResults
      testPath = name
      allTestsList.Add(name)
      Set App = CreateObject("QuickTest.Application")
  
      App.Launch
      App.Visible = False
      App.Open testPath
  
      SetQTPTestOptions(App)
      SetQTPRunOptions(App)
      SetQTPWebOptions(App)
  
      App.Folders.RemoveAll
  
      Dim qtpTest, qtpResultsOpt
      Set qtpTest = App.Test
      Set qtpResultsOpt = CreateObject("QuickTest.RunResultsOptions")
  
      resultsPath = testPath &amp; "\RES1"
  
      qtpResultsOpt.ResultsLocation = resultsPath
  
      qtpTest.Run qtpResultsOpt ''// Run the test
  
      testResults = "Test Status: " &amp; qtpTest.LastRunResults.Status &amp; vbCrLf &amp; _
            "Last Error: " &amp; qtpTest.LastRunResults.LastError &amp; vbCrLf &amp; _
            "Detailed Results located at " &amp; qtpTest.LastRunResults.Path &amp; _
                 " can be viewed with the QTP Results Viewer Tool " &amp; vbCrLf
  
      If qtpTest.LastRunResults.Status &lt;&gt; "Passed" Then
          g_testRunPassed = False
          failureCount = failureCount + 1
          failedTestsList.Add(name)
          LogResults testResults, name        
      End If
  
      qtpTest.Close
  
      Set qtpResultsOpt = Nothing 
      Set qtpTest = Nothing 
  
      App.Quit
  
      Set App = Nothing 
  End Sub
  </code></pre>