Jump to content

run a .bat file


Recommended Posts

this is the command in my bat file

cscript.exe "C:\pwc\RunThisTest.vbs" "C:\pwc\Ipower New Client"

and the file is called Run Ipower Automation.bat

I'm pretty sure I'd use the_RunDos command - would I run the command or the file?

Edited by jloyzaga
Link to comment
Share on other sites

  • Moderators

Or convert the vbscript to AutoIt, and save yourself the hassle of mixing scripting languages :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

The reason I used vbscript is because I couldn't get autoit to work 

this is the vbscript 

'*******************************************************************
'RunThisTest
'by Michael Innes
'November 2012

testResourcePath = "C:\pwc\Logs\"

'Getting the test path
Dim objArgs
Set objArgs = wscript.Arguments
testPath = objArgs(0)

'Determining that the test does exist
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
DoesFolderExist = objFSO.FolderExists(testPath)
Set objFSO = Nothing

If DoesFolderExist Then
    Dim qtApp 'Declare the Application object variable
    Dim qtTest 'Declare a Test object variable
    Set qtApp = CreateObject("QuickTest.Application") 'Create the Application object
    qtApp.Launch 'Start QuickTest
    qtApp.Visible = True 'Make the QuickTest application visible
    qtApp.Open testPath, False 'Open the test in read-only mode
    Set qtTest = qtApp.Test

    'Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
    'qtResultsOpt.ResultsLocation = testResourcePath ' Specify the location to save the test results.
    'qtTest.Run qtResultsOpt,True 'Run the test and wait until end of the test run

    qtTest.Run 'Run the test
    qtTest.Close 'Close the test
    qtApp.Quit
Else
    'Couldn't find the test folder. That's bad. Guess we'll have to report on how we couldn't find the test.
    'Insert reporting mechanism here.
End If

Link to comment
Share on other sites

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_type=a3x
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
$sPath = "C:\Program Files (x86)\HP\Unified Functional Testing\bin\mdrv.exe"
ShellExecute($sPath, ' -usr "C:\pwc\PWC-QTP\PWC-QTP.usr"')
 If @error Then ConsoleWrite("Run failed with error: " & @error & @CRLF)

Link to comment
Share on other sites

  • Moderators

This is how I would do (untested) your vbscript. Sticking with the args method in the VBScript, you would need to compile to exe and then pass the $testPath argument as a command line. Something like this:

Run with args pointing $testPath to C:\Temp\Temp: C:\Users\Me\Desktop\test.exe /C:\Temp\Temp

#include <MsgBoxConstants.au3>
If Not @Compiled Then Exit(MsgBox($MB_OK + $MB_ICONWARNING, "", "This script must be compiled and run from the command line, passing the appropriate arguments"))


$testResourcePath = "C:\pwc\Logs\"

;Getting the test path
$testPath = $CmdLine[1]

;Determining that the test does exist
If FileExists($testPath) Then
    $qtApp = ObjCreate("QuickTest.Application") ;Create the Application object
        If IsObj($qtApp) Then
            $qtApp.Launch ;Start QuickTest
            $qtApp.Visible = True ;Make the QuickTest application visible
            $qtApp.Open($testPath, False) ;Open the test in read-only mode
            $qtTest = $qtApp.Test
            $qtTest.Run ;Run the test
            $qtTest.Close ;Close the test
            $qtApp.Quit
        Else
            MsgBox($MB_OK + $MB_ICONERROR, "My Script", "Failed to Create QuickTest Object")
        EndIf
Else
    MsgBox($MB_OK + $MB_ICONERROR, "My Script", "Test path does not exist.")
EndIf

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

I'm not sure how to make it any clearer, but I'll try: C:\Users\Me\Desktop\test.exe is the path to your executable that you type into the run line. /C:\Temp\Temp is the argument you pass to the script. As I stated in my previous post, this is the path to the folder you want to point to. It looks like you're pointing at a file.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...