cancel
Showing results for 
Search instead for 
Did you mean: 

Check process exists for username?

PierceClements
Level 3

​​Hello everyone,

Working with many RPA developers over only a few Virtual Machines(VM), there will often be 3-5 people on the same VM running the same process, e.g. "iexplore".

We all occasionally run into some calculation & decision issues on:
1. BO: Utility - General, ACTION: Process Exists, then
2. BO: Close Process Window. (this is an in-house BO that loops to close all but 1 window of an application)

I'm not allowed to mess with step two of the logic, which leaves me with step one. Is there an object/way to determine "Process Exists by User Name"? Is the only solution using VBA, and if so can anyone point me in the direction of some copy/paste magic?

2 REPLIES 2

There are a few examples here which uses powershell, cmd and VB/C# code to kill process launched by specific user. This might be helpful as a reference. https://stackoverflow.com/questions/426573/how-do-you-kill-a-process-for-a-particular-user-in-net-c

TobiasArnold
Level 6
Hi Pierce,

some of the standard Blue Prism VBO e.g. 'Utility - General' can not be used in a multi user environment. We uses our own VBO. Mostly you didn't need to know if a process exists for a special user, but you need to know if a process exists for the current user. Here is a simple trick to check: Take the session ID of the current logged in user and filter the process list:
var currentSessionId = Process.GetCurrentProcess().SessionId;
var process = Process.GetProcessesByName(processName).FirstOrDefault(p => p.SessionId == currentSessionId);
exists = process != null;
​