The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:
Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> HP Functional Testing / Mercury QuickTest Pro / QTP

Pages: 1
Prashant Bhide
Member


Reged: 07/11/05
Posts: 55
Loc: mumbai
How to execute dos commands from QTP ? Tried but not working
      #215985 - 11/29/05 11:08 PM

I tried the following code

Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("cmd")
Set oExec = WshShell.Exec("cd\")

After executing this code I got error that 'System cannot find the file specified' on last line. How to go about it ?

Even following is also not working

Dim oShell
Set oShell = WScript.CreateObject ("WSCript.Shell")
oShell.run "calc"
oShell.run "cd\"

Its giving error that 'WScript' object not found.


Post Extras: Print Post   Remind Me!   Notify Moderator  
aries
Member


Reged: 10/26/02
Posts: 61
Loc: Trichy, Tamil Nadu, India
Re: How to execute dos commands from QTP ? Tried but not working
      #215986 - 11/30/05 02:05 AM

What's your objective, what you want to do?
There is no file called "cd\" right?


Post Extras: Print Post   Remind Me!   Notify Moderator  
Jon H
Member


Reged: 06/30/05
Posts: 100
Loc: UK
Re: How to execute dos commands from QTP ? Tried but not working
      #215987 - 12/02/05 03:20 AM

wouldn't you then need to recognise the cmd window and type "cd /" in there not on a run box like shell does

Post Extras: Print Post   Remind Me!   Notify Moderator  
MoTest
Advanced Member


Reged: 02/21/05
Posts: 477
Loc: Northern Ireland
Re: How to execute dos commands from QTP ? Tried but not working
      #215988 - 12/02/05 03:22 AM

From the QTP Help (a most wonderful addition to the software I might add)
quote:

Running DOS Commands
You can run standard DOS commands in your QuickTest test using the VBScript Windows Scripting Host Shell object (WSCript.shell). For example, you can open a DOS command window, change the path to C:\, and execute the DIR command using the following statements:

Dim oShell

Set oShell = CreateObject ("WSCript.shell")

oShell.run "cmd /K CD C:\ & Dir"

Set oShell = Nothing

For more information, refer to the Microsoft VBScript Language Reference (choose Help > QuickTest Professional Help > VBScript Reference > VBScript).

**Note: to send a carriage return in your DOS command use the & symbol.

[ 12-02-2005, 03:32 AM: Message edited by: MoTest ]


Post Extras: Print Post   Remind Me!   Notify Moderator  
oliviabean
Member


Reged: 01/08/06
Posts: 56
Re: How to execute dos commands from QTP ? Tried but not working
      #215989 - 01/19/06 01:20 AM

Hi, i used a script similar to the above, but add a sleep statement like this:

Dim oShell
Set oShell = CreateObject("WScript.Shell")
'Start up command prompt
oShell.run"cmd.exe"
WScript.Sleep 500

while executing, it fails and reporting that the Object 'WScript' in the statement WScript.Sleep is not found.

How to resolve that?


Post Extras: Print Post   Remind Me!   Notify Moderator  
Ravi B
Member


Reged: 09/01/05
Posts: 42
Loc: Bangalore
Re: How to execute dos commands from QTP ? Tried but not working
      #215990 - 01/19/06 05:13 AM

Try this

Dim oShell
Set oShell = CreateObject("WScript.Shell")
'Start up command prompt
oShell.run "cmd.exe",1,1


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 43 anonymous users are browsing this forum.

Moderator:  IanFraser, Rajkumar_Rajangam, thorwath, TReddy, AJ, Tarun Lalwani, mwsrosso 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 6913

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5