473,836 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you determine the owner of a process

I can get all the processes on the local machine using "GetProcess es". 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 14708
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.Manageme nt

Module Module1

Class Sample_SelectQu ery

Public Shared Sub Main()
Dim selectQuery As SelectQuery = New SelectQuery("Wi n32_Process")
Dim searcher As ManagementObjec tSearcher = New
ManagementObjec tSearcher(selec tQuery)
For Each proc As ManagementObjec t In searcher.Get
Console.WriteLi ne(proc("Name") .ToString)
Dim s(1) As String
proc.InvokeMeth od("GetOwner", CType(s, Object()))
Console.WriteLi ne(("User: " & (s(1) + ("\\" + s(0)))))
Next
Console.ReadLin e()
End Sub
End Class
End Module
HTH

"Ken Soenen" wrote:
I can get all the processes on the local machine using "GetProcess es". 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.Manageme nt" statement. It says: " Namespace or type
'Management' for the Imports 'System.Managem ent' 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***@swigartc onsulting.com> wrote in message
news:95******** *************** ***********@mic rosoft.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.Manageme nt

Module Module1

Class Sample_SelectQu ery

Public Shared Sub Main()
Dim selectQuery As SelectQuery = New
SelectQuery("Wi n32_Process")
Dim searcher As ManagementObjec tSearcher = New
ManagementObjec tSearcher(selec tQuery)
For Each proc As ManagementObjec t In searcher.Get
Console.WriteLi ne(proc("Name") .ToString)
Dim s(1) As String
proc.InvokeMeth od("GetOwner", CType(s, Object()))
Console.WriteLi ne(("User: " & (s(1) + ("\\" + s(0)))))
Next
Console.ReadLin e()
End Sub
End Class
End Module
HTH

"Ken Soenen" wrote:
I can get all the processes on the local machine using "GetProcess es".
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.Manageme nt dll.

Scott Swigart - MVP

"Ken Soenen" wrote:
Scott,
Thanks for the help. For some reason or other it's choking on the
"Imports System.Manageme nt" statement. It says: " Namespace or type
'Management' for the Imports 'System.Managem ent' 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***@swigartc onsulting.com> wrote in message
news:95******** *************** ***********@mic rosoft.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.Manageme nt

Module Module1

Class Sample_SelectQu ery

Public Shared Sub Main()
Dim selectQuery As SelectQuery = New
SelectQuery("Wi n32_Process")
Dim searcher As ManagementObjec tSearcher = New
ManagementObjec tSearcher(selec tQuery)
For Each proc As ManagementObjec t In searcher.Get
Console.WriteLi ne(proc("Name") .ToString)
Dim s(1) As String
proc.InvokeMeth od("GetOwner", CType(s, Object()))
Console.WriteLi ne(("User: " & (s(1) + ("\\" + s(0)))))
Next
Console.ReadLin e()
End Sub
End Class
End Module
HTH

"Ken Soenen" wrote:
I can get all the processes on the local machine using "GetProcess es".
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***@swigartc onsulting.com> wrote in message
news:03******** *************** ***********@mic rosoft.com...
Sorry. You have to go into the Project | Add reference menu, and add a
reference to the System.Manageme nt dll.

Scott Swigart - MVP

"Ken Soenen" wrote:
Scott,
Thanks for the help. For some reason or other it's choking on the
"Imports System.Manageme nt" statement. It says: " Namespace or type
'Management' for the Imports 'System.Managem ent' 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***@swigartc onsulting.com> wrote in message
news:95******** *************** ***********@mic rosoft.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.Manageme nt
>
> Module Module1
>
> Class Sample_SelectQu ery
>
> Public Shared Sub Main()
> Dim selectQuery As SelectQuery = New
> SelectQuery("Wi n32_Process")
> Dim searcher As ManagementObjec tSearcher = New
> ManagementObjec tSearcher(selec tQuery)
> For Each proc As ManagementObjec t In searcher.Get
> Console.WriteLi ne(proc("Name") .ToString)
> Dim s(1) As String
> proc.InvokeMeth od("GetOwner", CType(s, Object()))
> Console.WriteLi ne(("User: " & (s(1) + ("\\" + s(0)))))
> Next
> Console.ReadLin e()
> End Sub
> End Class
> End Module
>
>
> HTH
>
> "Ken Soenen" wrote:
>
>> I can get all the processes on the local machine using "GetProcess es".
>> 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
3521
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
1398
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
4323
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 running. I don't see any members of class' Process' which allows me to get the name of the owner of the process.
2
5049
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 folder structure and naming conventions and then send a Net send message to those users telling them to rectify. The information I want to get is when you select the file/folder and then: Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
3
4020
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: ***************************************************** I am looking for a way to 'override' file security and read the Owner of a file to which I have no access. I am a system administrator, as such I have administrative rights to all the computers in the...
2
1915
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 Employee only has itself and Contractor. We did this as a hierarchy where the higher (i.e. Executive) has a member of the one directly below (i.e. Manager): Executive has a member of Manager Manager has a member of Employee
2
3441
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 back to me everytime. The error I have on that project said: "An unhandled exception of type 'System.EntryPointNotFoundException' occurred in TestSysaudit.exe
1
1788
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 new child In this case who becomes the owner of this child process. Is it the thread that spawned becomes the owner or is the main program becomes the owner of that child process. Thanks, -V
2
2190
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 runs full). For temptables (NON-DGTT) you can use db2pd to find the owner (- tcbstats) here the application handle (agent id) is listed. But this won't help for DGTTs, because this information isn't given. --Serge : This would be a nice...
0
9813
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9665
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10835
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10541
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10585
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5645
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5818
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.