UiPath - Kill Process for Current User

uipath kill process for current user
UiPath - Kill Process for Current user

Kill Process activity in UiPath terminates a specified process from the machine/server.

This activity kill process for every user session, and this would create problem for other users working on the server. This would also create problem to work with High Density Robots features of UiPath.

In order to avoid these issues and for good practice in development, we should kill process for current user only on machine/server.

Below is the uipath code to kill process for current user.

Step 1 – Take a variable/argument (string array) contains the process names needed to be killed.

in_ProcessArrayToKill = New String(){"excel", "iexplore"}

kill-process-for-current-user-uipath
Initialize String Array with Process names to be killed

Step 2 – Get All Processes

processList = Process.GetProcesses

kill-process-current-user
Get All Processes

Step 3 – Get Current session Username

currentUsername = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Replace(System.Environment.UserDomainName+"\","")

uipath-kill-process-for-current-user
Get Current Session Username

Step 4 – Perform "For Each" loop over all processes

Use "For Each" loop over variable "processList" and take the "TypeArgument" as "System.Diagnostics.Process"

Step 5 – Inside "For Each" loop, get username of the current process inside loop

itemProcessUsername = itemProcess.StartInfo.Environment("Username")

uipath-kill-process
Get Process Username

Step 6 – Inside "For Each" loop, check condition using "If activity" whether the current process is under "processList" to be killed and current process username is of current session username

uipath-kill-process-excel
Check Process for Current User

Step 7 – Inside "For Each Loop", If the above condition meets then kill the process

uipath-kill-process-for-current-user
Kill Process Properties

Comments

  1. The process was, fill the chamber with measured amount of the granules and put the mold in the slot under. After permitting time for the plastic to soften, you pushed down the plunger to inject it into the mold. I had molds for tanks and troopers and construction tools like Shower Curtains bulldozers, and the plastic materials in several of} colours.

    ReplyDelete

Post a Comment

Popular posts from this blog

UiPath - Convert String to DateTime

UiPath - Initialize List and Assign Values to List

UiPath - Initialize Array and Assign value to Array