I'm writing code to shutdown a process in a Terminal Service Environment and I'm running into the problem that it shuts down that process for all users.
I know the user that is trying to shutdown the process now I need to find out the username for each process.
Here is the code I'm currently using to shutdown the process. Is there a way I can find out the username for each process with the process object?
I found a lot of posts to get the username of the person logged onto the system, but I need the username for each process. I'm using VB.NET 2005.
Thanks in advance for the help!
I know the user that is trying to shutdown the process now I need to find out the username for each process.
Here is the code I'm currently using to shutdown the process. Is there a way I can find out the username for each process with the process object?
Code:
'This method will shutdown a given process name
Dim instance As Process
Dim myProcesses() As Process
'Set the array to all the processes running w/ the same name
myProcesses = Process.GetProcessesByName(strProcessName)
'Stop a process
For Each instance In myProcesses
instance.Kill()
instance.WaitForExit()
Next
I found a lot of posts to get the username of the person logged onto the system, but I need the username for each process. I'm using VB.NET 2005.
Thanks in advance for the help!