There are various ways using which we can launch applications in QTP/UFT One. In this article, let us discuss six such different methods:
1. SystemUtil.Run
SystemUtil.Run ( FileName, Parameters, Path, Operation )
- FileName – The name of the file you want to run.
- Parameters (optional) – If the specified FileName is an executable file, use the Parameters argument to specify any parameters to be passed to the application.
- Path(optional) – The default directory of the application or file.
- Operation(optional) – The action to be performed. If this argument is blank (“”), the open operation is performed. The following operations can be specified for the operation argument of the
SystemUtil.Run
 method:- open – Opens the file specified by the FileName parameter. The file can be an executable file, a document file, or a folder. Non-executable files are open in the associated application.
- edit – Launches an editor and opens the document for editing. If the FileName argument does not specify an editable document file, the statement fails.
- explore – Explores the folder specified by the FileName argument.
- find – Initiates a search starting from the specified folder path.
- print – Prints the document file specified by the FileName argument. If the specified file is not a printable document file, the statement fails.
Example Usage:Â
SystemUtil.Run "C://Program Files/Internet Explorer/IEXPLORE.EXE"
2. InvokeApplication
This command is mainly used for backward compatibility i.e. to use with the lower versions of QTP (below QTP 6.0).
InvokeApplication("Full URL as Parameter")
Example Usage:
InvokeApplication "C://Program Files/Internet Explorer/IEXPLORE.EXE http://www.yahoo.com"
3. VB Script to invoke application
- Create a WScript.shell object.
- Use the run method to launch the application. If the path to your executable contains spaces, use Chr(34) to ensure the path is contained within double quotes.
- When done, set the shell object to nothing to release it.
Example:
Dim oShellSet oShell = CreateObject ("Wscript.shell")' 'Example 1 - run a batch file: oShell.run "F://jdk1.3.1/demo/jfc/SwingSet2.bat" 'Example 2 - run a Java jar file: oShell.run "java -jar F://jdk1.3.1/demo/jfc/SwingSet2/SwingSet2.jar" 'Example 3 - launch Internet Explorer: oShell.run Chr(34) & "C://Program Files/Internet Explorer/IEXPLORE.EXE" & Chr(34) Set oShell = Nothing
4. IE Automation Object Model
Using IE AOM, create an object of type InternetExplorer
 Use Navigate method to launch a URL.
Set oIE = CreateObject("InternetExplorer.Application") oIE.Navigate "https://www.google.com/" oIE.Visible = True ...... ...... Set oIE = Nothing
5. Trivial but useful method
If nothing works, you might try this:
Use the Start -> Run dialog of Windows.
- Add the Windows Start button to the Object Repository using the “Add Objects” button in Object Repository dialog.
- Open the Run dialog (Start -> Run), and learn the “Open” edit field and the “OK” button into the Object Repository.
- Switch to the Expert View, and manually add the lines to open the Run dialog.
Example:Window("Window").WinButton("Button").ClickWindow("Window").Type("R")
- Manually enter the lines to enter the information to launch the application, and click the “OK” button of the Run dialog.
Example:
Dialog("Run").WinEdit("Open:").Type "C://Windows/System32/notepad.exe" Dialog("Run").WinButton("OK").Click
6. WebUtil Object
In UFT 14.01 update, HPE introduced two new methods for WebUtil Object. LaunchBrowser
 and LaunchMobileBrowserWithID
Using LaunchBrowser method you can launch applications across desktop and mobile devices. The syntax for LaunchBrowser is
WebUtil.LaunchBrowser Browser, [device_model, device_manufacturer, device_ostype, device_osversion]
where:
- Browser: Name of browser to be launched. Ex: CHROME, FIREFOX, IE
- device_model: The model of the selected device.
- device_manufacturer:Â The name of manufacturer of the selected device.
- device_ostype: The OS running on the device.
- device_osversion:Â The OS version running on the selected device.
Parameters in square brackets are optional and they are meant to be used for mobile browsers only.
Example:
The following example launches the Chrome browser on an iOS Apple 5s device.
WebUtil.LaunchBrowser "MOBILE_CHROME", "Apple_5s", "Apple", "IOS", "10.1.3"
Using LaunchMobileBrowserWithID method you can launch a mobile browser on an iOS or an Android device using the Mobile Center’s device ID.
WebUtil.LaunchMobileBrowserWithIDÂ Browser, device_ostype, device_id
where
- Browser: Name of browser to be launched. Ex: MOBILE_HPWEB, MOBILE_CHROME, MOBILE_SAFARI
- device_ostype: The OS running on the device.
- device_id: The id assigned to the device by Mobile Center.
Example:
WebUtil.LaunchMobileBrowserWithID "MOBILE_CHROME", "IOS", "02"
Hi,
I am trying to write code to connect to my VPN. However whenever i am opening a VPN exe using SystemUtil the VPN’s lock icon is automatically going into the hidden section where we can see the date & time of machine. Can you please tell me how can i highlight & this VPN object.
Hi , Myself Lakshmi. I am learning UFT now. I faced one issue while launching an application. I observed even before my code “SystemUtil.Run “C:\Program Files (x86)\Internet Explorer\iexplore.exe”, “https://xyz.com”” is getting executed, I see the webbrower is opened with the above link. When this piece gets run, one more webpage is getting opened. Kindly help me to resolve this.
Hi,
How to restrict the duplication of objects.
My application is desktop based .Uft recognizes many objects as Winobject.Is there any solution for this??
Hello Friends,
I have a small query. I have a desktop application and it uses a login ID and password. I need a script that will load the application on startup and then input the ID and password automatically.
Please let me know if it is possible.
Ankur , I have an window based Java application , I want to invoke the bat file(windows batch file) from c folder.
Could you please provide the script for this
@Ram: Show us what you have tried already?
when i try to open up IE in qtp on windows8, i get the error message
“the instruction at referenced memory at . the memory could not be read”
Hi Ankur,
I have to launch a Terminal Emulator host. I have tried all the above solutions but the application is not launched. QTP 10 on windows 7 Operating system.
Please find the below trials i have made, none of the below worked. The same path checked it manually works fine.
InvokeApplication “C://ProgramData//IBMSys//SWDlog//PCOMM//Scripts//StartHost.exe”
systemutil.Run “C://ProgramData//IBMSys//SWDlog//PCOMM//Scripts//StartHost.exe”
systemutil.Run “C:/ProgramData/IBMSys/SWDlog/PCOMM/Scripts/StartHost.exe”
Dim oShell
Set oShell = CreateObject (“Wscript.shell”)
oShell.Run Chr(34) & “C://ProgramData//IBMSys//SWDlog//PCOMM//Scripts//StartHost.exe”
Set oShell = Nothing
Any help would be lot appreciated.
[SOLVED]
‘—————————————————–
If NOT TeWindow(“TeWindow”).TeScreen(“screen5672”).TeField(“Home”).Exist(5) Then
Systemutil.Run “C:\Users\” &strUser &”\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Run”
Wait(1)
filePath = Dialog(“Run”).WinEdit(“Open:”).GetROProperty(“text”)
If Ucase(filePath) Ucase(“C:\ProgramData\IBMSys\SWDlog\PCOMM\Scripts\StartHost.exe”) Then
Dialog(“Run”).WinEdit(“Open:”).Type “C:\ProgramData\IBMSys\SWDlog\PCOMM\Scripts\StartHost.exe”
Dialog(“Run”).WinButton(“OK”).Click
End If
End If
Hi Ashish,
If the position of the object is changing use description.create method
Syntax:
Set k = description.create()
k(“micclass”).value= “WinButton”
k(“htmlid”).value= ” ” {Use HTMLID value}
k(“Name”).value = ” “{Use NAME value}
set kch = Browser(“micclass=browser”).page(“micclass:=page”).childobject(k)
c = kch.count
msgbox c
kch(0).highlight
kch(0)click
Hi Friends,
How to capture the run time browser name using Descriptive progamming,for eg, after launching yahoo mail box we can view the title as (“unread mails)- username – Yahoo!Mail – but as soon as the mails are read, unread values will be changing, how can we handle this in descriptive…Plz reply
Hi,
Please Help me..
I am using QTP 11.00 to test a Desktop Java Application which generates a PDF and i m using PDF 7.0 .
Problem is when the QTP tries to close the PDF the system hangs and need to be restarted..
not every time system hangs sometimes it hangs on 1st iteration sometimes it works smoothly till 50 iterations also..
the code that encounters problem is
If Window(“Adobe Reader”).Exist(20) then
Window(“Adobe Reader”).Activate ..
Please let me know wat to do to run the test smoothly…
Hi Ankur,
I have used “4) Trivial but useful method” this approach and it was working fine earlier for opening notepad.
Now when I run the same code in local it works .But fails in server machine with error:
Cannot find the “Open:” object’s parent “Run” (class Dialog). Verify that parent properties match an object currently displayed in your application.
Line (33): “Dialog(“Run”).WinEdit(“Open:”).Type “notepad””.
The dialog is in OR,and it works in local machine.Do you see any familiar server issue here .Pls suggest .
“C:\Program Files\app\app.exe” aconfig_test.txt
this is a exe file with config file. this is shortcut target. How to launh via QTP? Thanks
Hi,
i want to know how to open “C:\Windows\System32\drivers\etc” >” hosts” file in notepad , as this file is un known type i would need to open it in Notepad format
thanks
Vishu
Dialog(“Run”).WinEdit(“Open:”).Type “c:WINNTsystem32notepad.exe”
Dialog(“Run”).WinButton(“OK”).Click
Sir ji this one is not working.
One more thing ,i am facing in my qtp exprt view
for every enter press it is giving []
this box .i don’t know what is that .
Please do needful for me
HI,
I am trying to launch outlook from an exchange server in QTP to record few actions to test later. The exchange server is on a separate network. How do I launch?
Thanks for your support
Hi
I have a question regarding wep applictaion recording. When I am adding a website to object repository its storing as a winedit rather Browser and at the same time its not letting record that website too. Please help me.
sm
I am stuck in a very critical situation here. I hope one of my fellow friends will help me out.
Basically, i am trying to launch an application via QTP Script.
I have tried various methods( SystemUtilRun, creating an external .vbs file etc.).But when the command is executed i see a message which says “Close the app” or “Debug”.
Just for investigation purposes i clicked on debug and it gave me a “Access Violation followed by some code etc.” on the screen.
Please shed some light as to how I can lauch this app using QTP or anyother way during my script is running.
I have the entire script ready but the only issue to launch the app.
Thanks in Advance.
Good Luck.
email jassi322@hotmail.com
I’m working on Mercury QTP 9.5. A QTP script was created that executes numerous actions. From that script, there were separate vbs scripts created to execute each action independently. When they are initially executed, it begins to startup QTP but then it generates the following message: “windows script host” errors. How can I get the vbs scripts to run successfully?
Hello Ankur
Plz help me out..
I have QTP 9.2 Setup but don’t know how can i Enable that Air Ticket Booking Application….
or i have to download seperate that Air Ticket Application…
Plz Tell me what i have to do…?
My Mail-Id is : jatinderjain@gmail.com
Hi,
I have been spending more than 8 hours to get the picture on the below scenario and finally i am posting my query to this forum
Scenario:
I have a one link called “Data Name” under this i could see some 200 data field values . By default all these field values shown in ascending order and when u click on this link manually page refreshes and still it will show the data fields in ascending order(Note: Here number of clicks on this link is “one” as of now) and by click on this link once again then the data field values will be shown in descneding order(Note: Here number of clicks on this link is “two” as of now)
Query: Here i need to find the number of clicks on a link “Data Name”
by this way i can put this logic in my code (Ex: if number of clicks are even then it will display in descending order, if number of clicks on this link are odd number then i could consider that displaying of fields are in ascending order
Please help in this regard to find the number of clicks on a particular link
Hi Ankur,
Thanks for your reply. I have one more question.
Is there any way through which we can test UI of the Microsoft outlook using VBScript in QTP?
For ex: to view grouping of certain outlook calendar items according to their priority.
Yeah Sreedevi.
Check the post on QTP with Quality Center
Hi, how can we schedule a test run from Quality Center to run a certain number of tests at the specified time?
Some Examples of launching an application:
‘launching the application using SystemUtil
SystemUtil.Run “C:windowssystem32calc.exe”
‘Closing the application using SystemUtil
Systemutil.CloseProcessByName “calc.exe”
‘Launching application using invoke application option. It is not recommended to use as it is for backward compatability of QTP.
invokeapplication “c:windowssystem32calc.exe”
‘Closing the application using SystemUtil
Systemutil.CloseProcessByName “calc.exe”
‘Launching the application using VB Script
Dim oLaAp
Set oLaAp = CreateObject (“Wscript.shell”)
oLaAp.Run Chr(34) & “c:windowssystem32calc.exe” & Chr(34)
Set oLaAp = Nothing
‘Closing the application using SystemUtil
Systemutil.CloseProcessByName “calc.exe”
set fso=createobject(“scripting.filesystem”)
set FD=fso.opentextfile(“c:\Textfile.txt”,8,flase)
FD.write(“Hello World”)
Hi Ankur,
I have attended the QTP training program conducted by HP and started doing a prototype for our application.And realized, the cliche that practical is different from theory holds good here too.I have been facing a couple of issues and on googling, I found the solution for couple of problems on your site. You write detailed blogs which even a person not familiar with QTP would understand. Thanks for sharing your knowledge.
I have a query regarding parameter passing between actions.Could you please explain in detail as to how it works.
Thanks,
Nashi
Hi i am new in qtp. what is first step done in any project for using qtp. can u provide me some example so that i got cleared with basic fundamentals with practical knowladge. my email id is vikas41@gmail.com
Thanks,
vikas
what about security in the QTP???
and is it reliable????
I spent two bad days on solving the silly problem i’m facing.
It’s a windows application. There’s a dialog which has three winbuttons, whose positions keep on changing. when i look at their properties, there is no text or attached text.
I’m unable to identify the button i want to click.
can someone please tell me, how to do that ?? i have enabled smart identification, but that doesn’t work either.
Is there a property that i can define, which could help me click on the object i want.
Can’t use index or location, as the position keeps on changing on the screen.
Thanks and Advance,
Ashish
@nygel de: There is a link on the right hand side “Check already running process”.
Others: Please use Testing Tools forum for posting QTP questions.
Hi,
I just want to ask if there is a script to allow me to know if the application i am testing is already running?
Can someone please help me how to open a .pub file with notepad? Is there any command in QTP (like openAsTextStream)?
hi ankur,
Really very exicted to see this site abt QTP i was searching from many days .Thanku 4 solving all doubts and hav an excellent site. iam Doing my course on QTP still.
my doubt is y we go for AFW & detail use of Automation Frame work? wht are the best possible ways to write pgms.
Thanks&Regards,
Priyanaka
my mailId: meen_19@rediffmail.com
hi ankur,
Really very exicted after this site abt QTP i was searching from many days .Thanku 4 solving all doubts and hav a excellent site. iam Doing my course still.
my doubt is need detail use of Automation Frame work? wht are the best possible ways to write pgms.
Thanks&Regards,
Priyanaka
my mailId: meen_19@rediffmail.com
To open notepad app use following code.
Window(“Program Manager”).WinListView(“SysListView32”).Activate(“Run”)
Dialog(“Run”).WinEdit(“Open:”).Type(“Notepad”)
Dialog(“Run”).WinButton(“OK”).Click
Window(“Notepad”).Close
Hi,
I like this QTP blog site. How can I post the questions? I’m new to QTP. I just started a .net project. I’m able to open the application automatically and recored some steps. But when I’m running the test, application is opening and rest of the steps are not running at all. is any body can help me?
Regards
Ram.
vramu1@gmail.com
go to hp site and download .net addins…..
may be it works better
hi friends
i have installed QTP 9.2 version on my PC. I am able to create a script but while running the script it pops up an error message “cannot find object….” I am using the application which suppotrs c sharp. So can anyone help me out how can i get rid of this error or how 2 add c sharp addins into my PC?
Hi Ankur,
I am really happy to see this blog, its really helpful for newbies like me.
I have one problem whenever I run IE through following script it launches two IE.
Systemutil.Run “C:Program FilesInternet ExplorerIEXPLORE.exe”
Please tell me what would be the reason and possible solution.
Thanks,
Chetan
Hey ankur I had a question.
When i try to open a .bat file using Wscript.shell , the application opens but it is not visible..what can be the possible way to make the application visible for further operation. When we double click on the bat file the application opens and it is visible.. but through qtp it is not visible.
if u want to acces from server, you must buy concurant licence from HP.
Thanks & Regards.
ramji
Hi Good morning.
This is Ramesh from Mphasis. I am working on one application using ASP.Net 2.0 where QTP validation is used. It is not to validate the existing ASP.Net application, but validate other test cases. I have to launch QTP using ASP.Net. Intially QTP was installed in all the clients system but now they want to install in Server. Now every one wants to use the QTP installed in the server.
Is it feasible?
Could you Please Proivde me the QTP license information provided by HP currently ?
Hi Friends
i need some information from you
i need some sample applications to improve my knowledge on Q.T.P rather than Flight application
that means any web application or Hospital Management application or Banking application
From where i can get the application i think a good response from this blog