How to kill process for specific (current) user

@Sajid_Masood
with myPID = Process.GetCurrentProcess.SessionID
you will get a marker of current user

getting the processes by name
currentProcessByName = Process.GetProcessByName(YourProcessName)

filtering to current user:
UserProcess = currentProcessByName.Where(Function (x) x.SessionId=myPID ).toArray

for a defensive kill have a look here and just combine both approaches:

1 Like