Terminate Processes

I am able to get a list of running processes, but I am having trouble terminating targeted processes.

I have a list of the running processes, and I want to terminate a process according to the process name.

For example, if explorer.exe is running and iexplore.exe is running with a bunch of other processes, what I want is to target explorer.exe and iexplorer.exe and end those processes without ending the others in the list.

I have tried the TerminateProcess function and I cannot get it to work.

If you have a function that will work by my passing a process name to it I would greatly appreciate it.

Function EndProcess(filename As String) As Boolean
Dim Process As Variant
For Each Process In GetObject("winmgmts:").ExecQuery("select * from Win32_Process")
If LCase(Process.Name) = LCase(filename) Then
Process.Terminate
EndProcess = True
End If
Next
End Function

Here are a few simple, working, games that you can use as-is or as the basis for your own games.
Tic-Tac-Toe
This is one of the simplest of all games.
The game allows for a choice of who goes first and keeps track of the number of wins for…

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…

Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code.
This l…