How do you record a command prompt operation in QTP?

Questions by sunnynaidu

Showing Answers 1 - 1 of 1 Answers

Deepak Kochhar

  • Sep 12th, 2007
 

You can't record the commpand prompt operation, only script it using the Windows Scripting Host shell object. 

The script can open the command window and then you can use the sendkeys method to type commands at the prompt. Note, the "~" character is used to send "Enter" command.

- The following script will open a command window and type commands in the window to ftp a file from the ftp server:

SystemUtil.Run "cmd","","L:",""
Dim oShell
Set oShell = CreateObject ("WSCript.shell")
oShell.run "cmd /K CD C: & cd temp & ftp <ftp server name>"
SystemUtil.CloseProcessByWndTitle "C:WINDOWSsystem32cmd.exe"
oShell.AppActivate "C:Windowsystem32cmd.exe - ftp <ftp server name>"
wait (2)
oShell.SendKeys "<ftp job name>"
oShell.SendKeys "~" 
....

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions