Sie könnten dies nutzen, um herauszufinden, wer der Prozesseigner ist, dann, wenn Sie haben, dass Sie Win32_Process verwenden können, um Töte den Prozess mit der Prozess-ID.
MSDN Win32_Process class details
MSDN Terminating a process with Win32_Process
Es ist sicherlich ein sauberer Weg, dies zu tun, ist aber hier, was ich kam mit. HINWEIS: Dies betrifft natürlich nicht mehrere Prozesse mit demselben Namen, aber ich denke, Sie können diesen Teil mit einem Array bearbeiten, um sie oder etwas Ähnliches zu halten. :)
strComputer = "."
strOwner = "A111111"
strProcess = "'notepad.exe'"
' Connect to WMI service and Win32_Process filtering by name'
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcessbyName = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " _
& strProcess)
' Get the process ID for the process started by the user in question'
For Each objProcess in colProcessbyName
colProperties = objProcess.GetOwner(strUsername,strUserDomain)
if strUsername = strOwner then
strProcessID = objProcess.ProcessId
end if
next
' We have the process ID for the app in question for the user, now we kill it'
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & strProcessID)
For Each objProcess in colProcess
objProcess.Terminate()
Next
Die Notwendigkeit, pskill zu installieren, ist nicht ideal. Ich würde eine Lösung bevorzugen, bei der ich nichts Neues installieren muss. – GlennH