Prashant Bhide
Member
Reged: 07/11/05
Posts: 55
Loc: mumbai
|
|
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.
|
aries
Member
Reged: 10/26/02
Posts: 61
Loc: Trichy, Tamil Nadu, India
|
|
What's your objective, what you want to do? There is no file called "cd\" right?
|
Jon H
Member
Reged: 06/30/05
Posts: 100
Loc: UK
|
|
wouldn't you then need to recognise the cmd window and type "cd /" in there not on a run box like shell does
|
MoTest
Advanced Member
Reged: 02/21/05
Posts: 477
Loc: Northern Ireland
|
|
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 ]
|
oliviabean
Member
Reged: 01/08/06
Posts: 56
|
|
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?
|
Ravi B
Member
Reged: 09/01/05
Posts: 42
Loc: Bangalore
|
|
Try this
Dim oShell Set oShell = CreateObject("WScript.Shell") 'Start up command prompt oShell.run "cmd.exe",1,1
|