Micro Focus QTP (UFT) Forums

Full Version: How to execute batch file from command prompt using QTP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In my project I have to run some bathc files in command prompt.
Afte executing this batch file it creates some tabnles and data in database.
I want to automate this process using the QTP.

Please help me if any one knows the code aur way how to procedd for this.
Hi Sachin,

we have to use Shell object to work with command prompt.
Let's see simple example here:

Set WSH = CreateObject("wscript.shell")
WSH.run "cmd /k CD C:\ & Dir"

if you want to see the command prompt you have to specify (/k) otherwise (/c) which will close the command prompt atomatically once the command is executed. Please specify the path of your batch file in the above code and then execute the script.

Let me know if you need any more info.

Thanks,
QTPKing.
Hi,
I tried using the code mentioned by you
i replaced Dir with ""N:\sneha\UpdatedUtility\runUtility.bat"...The error i get is "invalid directory name"
m unable to find a ETA
plz help

Thanks,
sneha