Pass the Shell.PID
property to this method (Win32 only):
Function KillProcess(ProcessID As Integer, ExitCode As Integer = 0) As Integer
Declare Function OpenProcess Lib "Kernel32" (DesiredAccess As Integer, InheritHandle As Boolean, ProcessId As Integer) As Integer
Declare Function TerminateProcess Lib "Kernel32" (ProcessHandle As Integer, ExitCode As Integer) As Boolean
Declare Function CloseHandle Lib "Kernel32" (Handle As Integer) As Boolean
Declare Function GetLastError Lib "Kernel32" () As Integer
Const PROCESS_TERMINATE = &h1
Dim pHandle, lasterr As Integer
pHandle = OpenProcess(PROCESS_TERMINATE, False, ProcessID)
lasterr = GetLastError()
If lasterr = 0 And TerminateProcess(pHandle, ExitCode) Then
lasterr - GetLastError()
Call CloseHandle(pHandle)
End If
Return lasterr
End Function