How to get the actual user name / owner associated with a process

How to get the actual user name / owner associated with a process.

I tried using process.StartInfo.EnvironmentVariables(“USERNAME”).
But this is returning the current user name of windows login account.
I want to get the owner associated with the process.
Can someone help me.

@MariaJosephina,

As per the UiPath studio, it is capturing the device ID of every machine and whenever we want to run the process, we must login into the machine and we need to provide the credentials. So, if we are running a process, the one who logged into will be the owner of the process. And the one you mentioned above will return that.

Can you please explain what you mean by the process associated owner?

@HareeshMR

My requirement is to kill all Excel process associated with the current user.
So when I am using this check, process.StartInfo.EnvironmentVariables(“USERNAME”), It is not giving me the actual owner of the process. But it is showing the owner as the current user and it will throw an exception saying : Could not kill the process.

I am getting the process list using ‘Get processes’ activity. It list out all the process in the server system(of current user and other users of the server)

1 Like

I don’t think it will kill the process which are associated with other users manually also.

So, you need to run the UiPath studio as Administrator and kill. Try this :slight_smile: @MariaJosephina

Hi Ma. Josephina,

You can set the ContinueOnError = true for your kill process activity so it will not throw exception moreover will just kill the process of the current user logged in.

@Emman_Pelayo
Iam doing that now. But the requriement is that, I want to get processes associated with currrent user only (username=Current user)

And Please note: the return value of process.StartInfo.EnvironmentVariables(“USERNAME”) is not correct it seems.

You can get the name using @MariaJosephina

system.Environment.UserName

1 Like

@HareeshMR
It will give me the current user name.

My requirement is : Get list of processes of current user only.(I don’t want the list of process associated with other users of the system)

1 Like

@MariaJosephina,

Use Get Processes activity and for each loop as in the screenshot

Change the item type to processes as in the screenshot

Is it working @MariaJosephina?

Hi MariaJosephina,

Did you find any solution? I have the same issue.

not yet

Have you tried running a powershell script as a admin account with this command “Get-Process -IncludeUserName”?

1 Like