How to kill process for specific (current) user

Kill Process activity is killing the process across all users. I have searched on forum but couldn’t find an exact solution. I want to kill the process for a specific user on the machine. Any ideas?

1 Like

Use .bat file
taskkill /f /t /im iexplore.exe /fi “USERNAME eq %USERNAME%”
Open .bat file using Start Process activity

1 Like

get the current user name by Environment.UserName .

Add check in the if condition that processName=“YourProcessName” AND UserName= Environment.UserName

then kill process


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

Thanks all guys. This solution was easy to use for me instead of using a bat file. I have done it using if else.

1 Like

Can you please tell me how exactly?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.