WORKING WITH QTP

TestEveryThinG

Close Application Process QTP

Posted by rajivkumarnandvani on May 3, 2009

REM This function kill the given process exe  through task manager
rem example call  fn_CloseApplication(“EXCEL.EXE”)

Public Function  fn_CloseApplication( byval sApplicationExe)
Dim strComputer
Dim objWMIService
Dim colProcesses
Dim objProcess
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)

Set colProcesses = objWMIService.ExecQuery (“Select * from Win32_Process Where Name = ‘”&sApplicationExe&”‘”)
For Each objProcess in colProcesses
objProcess.Terminate()
Next
Set objWMIService = Nothing
Set colProcesses=Nothing
End Function

Advertisements

5 Responses to “Close Application Process QTP”

  1. Thanks for your timely response.
    You asked if my QTP script ran from within QTP and the answer is yes. It runs the first time with the vb script but subsequent executions genterate the error mentioned before.
    Looks like this “close application process” above will close applications outside QTP. Will this listed below accomplish the same thing?

    Set qtApp = CreateObject(“QuickTest.Application”) ‘Create the Application object
    qtApp.quit ‘Close QuickTest Pro

    If not, then I need some help placing your code in the right place with the right parameters.

    Thanks,
    Frank

  2. Rajiv said

    idealy it should close the QTP but it will take time to close in proper way. Some time you can see qtp process in task manager too.
    Are you using same that is posted in my blog (means before launch you have to call fn_CloseApplication for close all qtp process.)

    rem call function fn_CloseApplication for close the instances/processes of QTP

    call fn_CloseApplication( “QTPro.exe”)
    call fn_CloseApplication( “QTAutomationAgent.exe”)

    rem launch QTP
    Set objQtpApp = CreateObject(“QuickTest.Application”)

    waiting for ur reply.. Best of luck..

  3. Anonymous said

    hiii this sounds good yaar
    thanks for above code

  4. Thanks for reading the blog..

  5. My coder is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using Movable-type on a number of websites
    for about a year and am anxious about switching to another platform.

    I have heard excellent things about blogengine.
    net. Is there a way I can transfer all my wordpress content into it?
    Any kind of help would be greatly appreciated!

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: