#include <Thread.au3>
$iTopNode = ProcessExists("cmd.exe")
_TerminateProcessTree($iTopNode)
Func _TerminateProcessTree($iTopNodePid, $iReserved = 0)
If Not ProcessExists($iTopNodePid) Then Return 0
If ($iReserved) Then
Local $aProcess = Eval($iReserved & $iTopNodePid)
If ($aProcess) Then
$aProcess = StringSplit($aProcess, ",")
For $i = 1 To $aProcess[0] - 1
_TerminateProcessTree($aProcess[$i], $iReserved)
Next
EndIf
Return ProcessClose($iTopNodePid)
Else
Local $pBuffer, $pBuffer1, $iSizeofBuffer
Local $iOffset, $iPid, $iParentId, $sRandom
_RTQuerySystemInformation(5, 0, 0)
$iSizeofBuffer = @Extended
$pBuffer = _RTHeapAlloc(@Extended)
_RTQuerySystemInformation(5, $pBuffer, $iSizeofBuffer)
$pBuffer1 = $pBuffer
$sRandom = Random(10000, 10000000) & Random(10000, 10000000) & ","
While 1
$iOffset = _RTReadBytes($pBuffer)
$iPid = _RTReadBytes($pBuffer + 68)
$iParentId = _RTReadBytes($pBuffer + 72)
Assign($sRandom & $iParentId, Eval($sRandom & $iParentId) & $iPid & ",", 2)
If ($iOffset) Then
$pBuffer += $iOffset
Else
ExitLoop
EndIf
WEnd
_RTHeapFree($pBuffer1)
Return _TerminateProcessTree($iTopNodePid, $sRandom)
EndIf
EndFunc ;==>_TerminateProcessTree
|