Results 1 to 5 of 5
  1. #1

    How to kill a specific process in TP?

    I want to kill a specifice process that is running on the machine. what is the way / command to kill?

  2. #2

    Re: How to kill a specific process in TP?

    Well, you should always try to shut a task down in a more graceful way. I have not found a process yet that could not be shut down with the methods that it exposes. If you are creating and closeing things and setting your object to nothing, then you should not need this unless the process that you are calling has some bad code.

    The following is one example, however, I have never had to use it yet:
    Shell("taskkill /f /im iexplore.exe /t")
    Hope this helps.
    Testing: TP 6.2 SP1 build 463, MS Access 2003
    TP 6.0 SP1 build 476, SQL 2005 DB.
    Test Environment:
    Clients on VMWare XP Workstation
    Run Clients useing VNC Ultra for Remote

    Application Under Test:
    IE 6 web apps
    Using Test Partner Sence 2007
    Using VBA Sence 1995
    VB3 - VB6, VBScript, VB.NET 1 - 4, Learning C#, SQL server 2005 - 2008

  3. #3
    Senior Member
    Join Date
    Nov 2005
    Valley Forge, PA

    Re: How to kill a specific process in TP?

    This subroutine is the same as "End Task" in Task Manager:
    You call it with the name of the executable, e.g notepad.exe.

    Public Sub Kill_by_PID(executable)
    Dim var1 As Variant
    Dim str1 As String
    Dim QueryText As String
    Dim strComputer As String
    Dim strText As String

    strComputer = "."

    QueryText = "SELECT * FROM Win32_Process Where Name = " & "'" & executable & "'"

    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colProcessList = objWMIService.ExecQuery(QueryText)

    For Each objProcess In colProcessList

    End Sub


  4. #4

    Re: How to kill a specific process in TP?

    Dim AppsRunning As Object
    Dim myApp As Object
    Dim Wnmgts As Object
    10 Set Wnmgts = GetObject("winmgmts:")
    20 Set AppsRunning = Wnmgts.InstancesOf("win32_process")
    30 For Each myApp In AppsRunning
    40 If myApp.Name = "EXCEL.EXE" Or myApp.Name = "WINWORD.EXE " Then
    50 myApp.Terminate
    60 End If
    70 Next
    80 Set AppsRunning = Nothing
    90 Set Wnmgts = Nothing
    100 Set myApp = Nothing

  5. #5
    Senior Member
    Join Date
    Jan 2008
    North Carolina

    Re: How to kill a specific process in TP?

    We use Excel sheets alot for getting data and posting data. If a script fails during operation, these processes may not be stopped. We have come up with the following for killing all active Excel processes:

    'Excel clean up code
    ' This could be left over from a previous run that was successful or aborted
    Dim lHwnd As Long
    'Find Excel's window handle
    lHwnd = FindWindow("XLMAIN", vbNullString)
    Do While lHwnd <> 0
    'Terminate the process
    ProcessTerminate , lHwnd
    'Find additional Excel's window handle
    lHwnd = FindWindow("XLMAIN", vbNullString)

    don, CSTP, QAD/TP user since 06
    Test Partner 6.3; QAD 6.1; QADLoad 5.9



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:29 PM.

Copyright BetaSoft Inc.