Skip to main content

Kill User Specific Process | UiPath | Automation

As you already have seen the situation where multiple users are logged in on single VDI. On this situation when we use Kill Activity directly to kill the process forcefully then it kills all processes without checking the user details. So we are writing small code so which you can use in your KillAllProcess workflow of Re-framework.
It will kill processes for logged in users and plays a vital role when running Bots in High Density Environment on Servers or standalone systems.
It works as per below:
  • It will get the process session Id as Process_Username.
  • It will get the current user session Id as Current_user.
  • Then Check the If condition that Process Name is Equals to your Input process Name and Process_Username=Current_user
  • Then it will pass process variable into the Kill Activity to kill that process.
1. Get Processes Activity, Output Variable: ActiveProcesses


2. Use For Each Loop and Pass the Above variable inside it and make the TypeArgument as System.Diagnostic.Process


3. Inside For Each Loop, Make two Variable, Type as Integer (Int): Process_Username, Current_user.

4. Use If condition to check the process name and check whether both the variables have equal values: Process_Username, Current_user like shown above.
For Eg: I want to kill the Excel.
(process.ProcessName.ToUpper ="EXCEL") and (Process_Username=Current_user)

If you want to read more, you can Go to forum, i also found one more solution on forum:
https://forum.uipath.com/t/how-to-kill-process-for-specific-current-user/262352

Happy Automation!!

Comments