Dim hSnapShot As Long, uProcess As PROCESSENTRY32
Dim r As Long
Dim eCode As Long
Dim pHandle As Long
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&)
uProcess.dwSize = Len(uProcess)
r = Process32First(hSnapShot, uProcess)
Do While r
If LCase(Mid$(uProcess.szExeFile, 1, InStr(1, uProcess.szExeFile, vbNullChar) - 1)) = LCase([ИМЯ_ТВОЕГО_ЕХЕ]) Then
pHandle = OpenProcess(PROCESS_TERMINATE, False, uProcess.th32ProcessID)
Call GetExitCodeProcess(pHandle, eCode)
Call TerminateProcess(pHandle, eCode)
End If
r = Process32Next(hSnapShot, uProcess)
Loop
CloseHandle hSnapShot
Private Const TH32CS_SNAPHEAPLIST = &H1
Private Const TH32CS_SNAPPROCESS = &H2
Private Const TH32CS_SNAPTHREAD = &H4
Private Const TH32CS_SNAPMODULE = &H8
Private Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Private Const TH32CS_INHERIT = &H80000000
Private Const PROCESS_TERMINATE As Long = &H1
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
Option Explicit
dim WMI
dim SQuery
dim Processes
dim Process
dim WshShell
Dim ArgProcessName
'Создаем объект WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.Count<>1 Then
WshShell.Popup "Ну указано имя удаляемого процесса.",5, _
"Завершение процесса."
WScript.Quit(1)
Else
'Получим имя процесса переданное в аргументе
ArgProcessName=WScript.Arguments(0)
'Соединяемся с WMI
set WMI=GetObject("winMgmts:")
'Формируем текст запроса
SQuery="SELECT * FROM Win32_Process WHERE Name='" & _
argprocessname & "'"
'Создаем коллекцию-результат запроса
set Processes=WMI.ExecQuery(SQuery)
WshShell.Popup "Завершаем просессы с именем " & _
ArgProcessName,5,"Завершение процесса"
'Цикл по всем элементам коллекции
for each Process in Processes
'Завершаем процесс
Process.Terminate()
Next
End if
WScript.Quit(0)
...там это все будет, мало таго, можно будет, удалит сам процесс, файл процесса, и если он был автозагрузке, то и это тоже...вот....и куча другого....так что ждите!!!
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 176