Wednesday, July 13, 2011

Work with command prompt using QTP(vbscript)

We can use Windows Shell object to start a command prompt and execute the command.

In the following i want to list all files\folders in C drive:
Set wscriptObj=createobject("WScript.Shell")
wscriptObj.Run "cmd /K cd c:\ & dir"

When i execute the above statement, it opens the command prompt and execute dir command. You are free to use any command you want as per your needs.

No comments: