How to close QTP Application through Code/Script/Descriptive Programming?


Close QTP Application:
Well,Question is simple but answer is little bit  complex. Here you need to search the desired application process on Win32_Process list.Microsoft MSDN has a good source of information on this topic. I am going to show the code without giving much explanation; Hope the code itself serves as a source of explanation 🙂

Please have a quick look on the above topic:
The Win32_Process:Win32 classes, such as Win32_NetworkAdapter or Win32_Process, monitor and manage system hardware and features. Generally, these classes are located in the root\cimv2 WMI namespace. The following table lists the Win32 class categories.WMI class represents a process on an operating system.
Source: http://msdn.microsoft.com/en-us/library/aa394084(v=VS.85).aspx
Code:

Function ClosemyApp()
Dim iCount iCount=0
Set oMyobj=GetObject(“winmgmts:\\.\root\CIMV2”)Set sCollectedProcess=oMyobj.ExecQuery(“select * from Win32_Process
where name=’QTPro.exe’ “)
For each iCount in sCollectedProcess iCount.Terminate()Next
Set sCollectedProcess=NothingSet oMyobj=Nothingmsgbox “Hurray!”
End Function

Thank You!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: