1- CloseProcessByHwnd

Closes a process that is the owner of a window with the specified handle.

QTP-closeprocessby

Example –

Sub CloseProcessByHwnd_Example()
'The following example retrieves the handle of the Notepad window, ‘and then uses the CloseProcessByHwnd method to close the ‘notepad application.
hWnd = Window("Notepad").GetROProperty("hwnd")
SystemUtil.CloseProcessByHwnd (hWnd)
End Sub

2- CloseProcessById

Closes a process according to its Process ID (PID).

Example –

Sub CloseProcessById_Example()
'The following example retrieves the process ID of the Notepad ‘window, and then uses the CloseProcessByID method to close the ‘notepad application.
PID = Window("Notepad").GetROProperty("process id")
SystemUtil.CloseProcessById (PID)
End Sub

3- CloseProcessByName

Closes a process according to its name.

Example –

Sub CloseProcessByName_Example()
'The following example uses the CloseProcessByName method to ‘close any open instances of Notepad. If the only instances of ‘Notepad that are open are those opened by the statements below, ‘then the MsgBox displays 3.
SystemUtil.Run "Notepad.exe"
SystemUtil.Run "Notepad.exe"
SystemUtil.Run "Notepad.exe"
MsgBox SystemUtil.CloseProcessByName("Notepad.exe")
End Sub

4- CloseProcessByWndTitle

Closes all processes that are owners of windows with the specified title.

Example –

Sub CloseProcessByWndTitle_Example1()
'The following example closes all top-level windows with a titlebar ‘that contains the string "Notepad", by specifying "Notepad" as a ‘regular expression.
SystemUtil.CloseProcessByWndTitle "Notepad", True
End Sub