473,413 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

How do you determine the owner of a process

I can get all the processes on the local machine using "GetProcesses". Now I
need to know the owner of each of these processes. If the Windows Task
Manager could talk, I would ask it.!!
Any help would be appreciated. I still haven't mastered the finer points(if
there are any) of finding something in VB.NET help. Sometimes it takes me
days to find even something simple.

thanks,
ken
Nov 21 '05 #1
4 14650
GetProcesses unfortunately doesn't return that piece of information. Here's
a link to another post that shows how:

http://groups.google.com/group/micro...6272a9b7ecd77b

Here's the code translated to VB.NET

Imports System.Management

Module Module1

Class Sample_SelectQuery

Public Shared Sub Main()
Dim selectQuery As SelectQuery = New SelectQuery("Win32_Process")
Dim searcher As ManagementObjectSearcher = New
ManagementObjectSearcher(selectQuery)
For Each proc As ManagementObject In searcher.Get
Console.WriteLine(proc("Name").ToString)
Dim s(1) As String
proc.InvokeMethod("GetOwner", CType(s, Object()))
Console.WriteLine(("User: " & (s(1) + ("\\" + s(0)))))
Next
Console.ReadLine()
End Sub
End Class
End Module
HTH

"Ken Soenen" wrote:
I can get all the processes on the local machine using "GetProcesses". Now I
need to know the owner of each of these processes. If the Windows Task
Manager could talk, I would ask it.!!
Any help would be appreciated. I still haven't mastered the finer points(if
there are any) of finding something in VB.NET help. Sometimes it takes me
days to find even something simple.

thanks,
ken

Nov 21 '05 #2
Scott,
Thanks for the help. For some reason or other it's choking on the
"Imports System.Management" statement. It says: " Namespace or type
'Management' for the Imports 'System.Management' cannot be found." And I
guess since this can't be found, the rest of the program falls apart. Any
ideas??

ken
"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:95**********************************@microsof t.com...
GetProcesses unfortunately doesn't return that piece of information.
Here's
a link to another post that shows how:

http://groups.google.com/group/micro...6272a9b7ecd77b

Here's the code translated to VB.NET

Imports System.Management

Module Module1

Class Sample_SelectQuery

Public Shared Sub Main()
Dim selectQuery As SelectQuery = New
SelectQuery("Win32_Process")
Dim searcher As ManagementObjectSearcher = New
ManagementObjectSearcher(selectQuery)
For Each proc As ManagementObject In searcher.Get
Console.WriteLine(proc("Name").ToString)
Dim s(1) As String
proc.InvokeMethod("GetOwner", CType(s, Object()))
Console.WriteLine(("User: " & (s(1) + ("\\" + s(0)))))
Next
Console.ReadLine()
End Sub
End Class
End Module
HTH

"Ken Soenen" wrote:
I can get all the processes on the local machine using "GetProcesses".
Now I
need to know the owner of each of these processes. If the Windows Task
Manager could talk, I would ask it.!!
Any help would be appreciated. I still haven't mastered the finer
points(if
there are any) of finding something in VB.NET help. Sometimes it takes
me
days to find even something simple.

thanks,
ken

Nov 21 '05 #3
Sorry. You have to go into the Project | Add reference menu, and add a
reference to the System.Management dll.

Scott Swigart - MVP

"Ken Soenen" wrote:
Scott,
Thanks for the help. For some reason or other it's choking on the
"Imports System.Management" statement. It says: " Namespace or type
'Management' for the Imports 'System.Management' cannot be found." And I
guess since this can't be found, the rest of the program falls apart. Any
ideas??

ken
"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:95**********************************@microsof t.com...
GetProcesses unfortunately doesn't return that piece of information.
Here's
a link to another post that shows how:

http://groups.google.com/group/micro...6272a9b7ecd77b

Here's the code translated to VB.NET

Imports System.Management

Module Module1

Class Sample_SelectQuery

Public Shared Sub Main()
Dim selectQuery As SelectQuery = New
SelectQuery("Win32_Process")
Dim searcher As ManagementObjectSearcher = New
ManagementObjectSearcher(selectQuery)
For Each proc As ManagementObject In searcher.Get
Console.WriteLine(proc("Name").ToString)
Dim s(1) As String
proc.InvokeMethod("GetOwner", CType(s, Object()))
Console.WriteLine(("User: " & (s(1) + ("\\" + s(0)))))
Next
Console.ReadLine()
End Sub
End Class
End Module
HTH

"Ken Soenen" wrote:
I can get all the processes on the local machine using "GetProcesses".
Now I
need to know the owner of each of these processes. If the Windows Task
Manager could talk, I would ask it.!!
Any help would be appreciated. I still haven't mastered the finer
points(if
there are any) of finding something in VB.NET help. Sometimes it takes
me
days to find even something simple.

thanks,
ken


Nov 21 '05 #4
Thanks. I probably should have known that. It works like a charm!!!!

ken

"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:03**********************************@microsof t.com...
Sorry. You have to go into the Project | Add reference menu, and add a
reference to the System.Management dll.

Scott Swigart - MVP

"Ken Soenen" wrote:
Scott,
Thanks for the help. For some reason or other it's choking on the
"Imports System.Management" statement. It says: " Namespace or type
'Management' for the Imports 'System.Management' cannot be found." And I
guess since this can't be found, the rest of the program falls apart. Any
ideas??

ken
"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:95**********************************@microsof t.com...
> GetProcesses unfortunately doesn't return that piece of information.
> Here's
> a link to another post that shows how:
>
> http://groups.google.com/group/micro...6272a9b7ecd77b
>
> Here's the code translated to VB.NET
>
> Imports System.Management
>
> Module Module1
>
> Class Sample_SelectQuery
>
> Public Shared Sub Main()
> Dim selectQuery As SelectQuery = New
> SelectQuery("Win32_Process")
> Dim searcher As ManagementObjectSearcher = New
> ManagementObjectSearcher(selectQuery)
> For Each proc As ManagementObject In searcher.Get
> Console.WriteLine(proc("Name").ToString)
> Dim s(1) As String
> proc.InvokeMethod("GetOwner", CType(s, Object()))
> Console.WriteLine(("User: " & (s(1) + ("\\" + s(0)))))
> Next
> Console.ReadLine()
> End Sub
> End Class
> End Module
>
>
> HTH
>
> "Ken Soenen" wrote:
>
>> I can get all the processes on the local machine using "GetProcesses".
>> Now I
>> need to know the owner of each of these processes. If the Windows Task
>> Manager could talk, I would ask it.!!
>> Any help would be appreciated. I still haven't mastered the finer
>> points(if
>> there are any) of finding something in VB.NET help. Sometimes it
>> takes
>> me
>> days to find even something simple.
>>
>> thanks,
>> ken
>>
>>
>>


Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ravi | last post by:
Hello everyone, Could any one tell me how to find the username(owner name) from a process handle or a process ID. ? thank you for your help Ravi
0
by: Durval Mateus | last post by:
Hello, I need to know the owner of a process, but the process class does not have that info. How can i retrieve the owner info? thanks in advance, Durval Mateus
1
by: DD | last post by:
I'm not sure that this msg made it out, the first time I sent it, so I am trying again. -- Win XP Home Edition I use System.Diagnostics.Process.GetProcesses()) to get info about the processes...
2
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified...
3
by: Dave Coate | last post by:
Hello again, I am going to re-post a question. I got some excellent suggestions from Rob and Mattias on this but their ideas did not solve the problem. Here is the original post: ...
2
by: gary.comstock | last post by:
We have setup 4 NT groups - Executive, Manager, Employee and Contractor. The premise is that an Executive has all of the privileges of Itself plus Manager plus Employee plus Contractor while an...
2
by: levimc | last post by:
I know that that topic may be old to you but I looked at other more- than-two-year-old topics related to mine. However, I didn't find them working for my project at all because its errors return...
1
by: Vishal Sethia | last post by:
Just trying to understand the behaviour of spawn. Consider I have a function which creates two threads. And in one of the threads I make a call to pexpect.spawn. spawn would fork and create a new...
2
by: stefan.albert | last post by:
Hello Ravi, what you want to do is very tricky, but possible. I've had this same problem - we want to identify the top user of tempspace and eventually force him off when using too much space (FS...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.