Posts

Showing posts with the label DOS

Execute a DOS command in QTP / CMD with QTP

REM using "Wscript.Shell" object we can work on command prompt in qtp. REM create one instance for "wscript.Shell" set oShell=CreateObject("Wscript.Shell") REM using run method we can invoke application REM /k this will display command prompt.we can also use /c but we can not see command prompt.It will disappear after execution. oShell.Run "cmd /k dir" REM for wait in ms WScript.sleep 3000 REM if we want use multiple commands we can use "&"(amp) symbol oShell.run "cmd /k dir & md qtp" REM we can use send keys method here {ENTER} will press enter button oShell.SendKeys "cd{ENTER}" REM if we want use multiple commands we can use "&"(amp) symbol oShell.Sendkeys "cd c:\{ENTER} md qtp ~" REM ~ for enter key {ENTER} = ~ oShell.Sendkeys "cd d: ~" set oShell=Nothing