Errors Encountered While Trying To Kill A Process

How to kill a user level process (Instead of trying to globally kill a process) ?

Issue Overview

When trying to kill a process the following error is encountered: Encountered errors while trying to kill a process.

RemoteException wrapping System.AggregateException: Encountered errors while trying to kill a process ---> RemoteException wrapping System.ComponentModel.Win32Exception: Access is denied



Resolution

  1. Automation should do the following
  1. Gets a list of all processes
  2. Gets the users name
  • System.Security.Principal.WindowsIdentity.GetCurrent().Name.Replace(System.Environment.UserDomainName+"\","")
  1. For each process, it checks what the username was when the process started.
  • process.StartInfo.Environment("Username")
  1. It also gets the SessionID of the process. (Needed to check that the process is not a service. It is possible that a service was started under a different username. You could get a false match.)
  2. If the Username for a process matches the current user and the processes name matches the specified process and the SessionID for the process is not zero, the automation will try to kill the process.

Where is the attached automation?

2 posts were split to a new topic: Kill a user level process (Instead of trying to globally kill a process)