Be careful while using SystemUtil.Run method

December 14, 2008

Be careful while using SystemUtil.Run method.....................
For projects, Tester generally uses SystemUtil -an inbuilt object of QTP- to launch application.
The sad part of this method is that it can not differentiate between explorer and iexplorer
As a result we generally get the below written Error thrown from QTP.
“Cannot identify the object parent. Make sure that……”

Object spy on browser bar revealed that it was being recognized as window instead of browser! Some more R & D and It was discovered that the problem lies with the SystemUtil.Run method. I was using
SystemUtil.Run “explorer”, .
When I changed that to

SystemUtil.Run “iexplore”, script started running fine. I guess while using explorer, QTP expects a file path and not a HTTP path on it.

To launch an application, I think a better alternative would be to create a shell object and launch applications using its Run method. It will take about 4 lines of code.(including declaration and destruction of shell object)

Even one of my friend Nilanjan recommended that instead of using System.Util .or run method.It is better to use the “cmd” that is the command format (simple dos)
Type path through QTP and run the file u want.
This is the most reliable approach,he suggested.
What do u say?

You Might Also Like


  1. Dim oShell
    Set oShell = CreateObject ("") "cmd /K CD C:\ & Dir"
    Set oShell = Nothing

    can be used..

  2. You gave the code for running it from 'cmd' as

    Dim oShell
    Set oShell = CreateObject ("") "cmd /K CD C:\ & Dir"
    Set oShell = Nothing

    Is that the one?? Please let me know.