Jump to content
Sign in to follow this  
jloyzaga

run a .bat file

Recommended Posts

jloyzaga

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

Share this post


Link to post
Share on other sites
JLogan3o13

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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
jloyzaga

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

Share this post


Link to post
Share on other sites
jloyzaga

#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)

Share this post


Link to post
Share on other sites
JLogan3o13

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

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
jloyzaga

sorry but what would the  /C:\Temp\Temp be pointing to?

 

so what would the command line be? is the C:\Users\Me\Desktop\test.exe  the compiled autoit script as above?

 

Sorry for being vague 

Share this post


Link to post
Share on other sites
jloyzaga

c:\pwc\N3T\runuft1.exe /C:\pwc\PWC-QTP\PWC-QTP.usr

 

is the command i used and I keep getting "Test path does not exist."

but its there

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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
Sign in to follow this  

×