Micro Focus QTP (UFT) Forums
Converting from WinRunner - command line executable - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Converting from WinRunner - command line executable (/Thread-Converting-from-WinRunner-command-line-executable)



Converting from WinRunner - command line executable - tmcmillin - 04-24-2008

We are implementing/converting from QTP from WinRunner and below is how we ran cleanup scripts (oracle) in WR:

invoke_application("ExportCleanup.cmd","user password database","K:\\Database_Cleanup_Scripts\\",SW_HIDE);

I was looking for an equivalent in QTP - so we don't have to redo totally everything... I have this that works so far, but it 1) doesn't use what we already have, 2) doesn't scale well for some cleanup scripts that are 20-30 lines long...

Code:
Sub DBCleanup(KScriptName, DSN, uName, uPwd)
    Set objConn=CreateObject("ADODB.connection")
    objConn.Open "Data Source=" & DSN & ";User ID=" & uName & ";Password=" & uPwd & ";LSProvider=ODP;"
    objConn.Execute KScriptName
    objConn.Execute "commit"
    Set objConn = Nothing
End Sub


I tried the wscript.shell object and didn't get any errors, but the data was not removed from the database properly:

Code:
Sub Test
    Set objShell=CreateObject("wscript.shell")
    'command to Execute
    strCommand="K:/Database_Cleanup_Scripts/ExportCleanupXI.cmd user pwd server"
             Set objExec=objShell.Exec(strCommand)
End Sub

Any ideas?