I have this code in VBA:
strTerminateThis = "notepad.exe"
Set objList = objWMIcimv2.ExecQuery _
("select * from win32_process where name='" & strTerminateThis & "'")
I want to narrow this query down by adding another where
to select a specific username that process is running under.
How can this be done? While name
is the name of the process, I wasn't able to find something simple like pid_owner
.
My goal would be to count how many Notepad processes are open under a specific user.
The Win32_Process
doesn't expose any property related to the owner of the process, so you only option is list all the procesess and then filter manually calling the method GetOwner
.