469,945 Members | 2,337 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

Who owns a running process?

Can you tell who owns a running process in .NET?

I can do the system.diagnostic.process object and see if an application of
the same name is running but I need to tell if the process is running by a
current user or by another user.

Anyone know how to do this?

Thanks

Nov 20 '05 #1
2 1382
Hi,
Add a reference to System.Management to your app. You can get
that info with the wmi.

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Process")

moReturn = moSearch.Get

For Each mo In moReturn

Dim arOwner(2)

mo.InvokeMethod("GetOwner", arOwner)

Debug.WriteLine(String.Format("{0} Owner {1} Domain {2}", mo("Name"),
arOwner(0), arOwner(1)))

Next

Ken

-------------------

"Scott Meddows" <sc******************@tsged-removeme.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Can you tell who owns a running process in .NET?

I can do the system.diagnostic.process object and see if an application of
the same name is running but I need to tell if the process is running by a
current user or by another user.

Anyone know how to do this?

Thanks

Nov 20 '05 #2
What are the other methods I can call from this?

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:O9**************@TK2MSFTNGP11.phx.gbl...
Hi,
Add a reference to System.Management to your app. You can get
that info with the wmi.

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Process")

moReturn = moSearch.Get

For Each mo In moReturn

Dim arOwner(2)

mo.InvokeMethod("GetOwner", arOwner)

Debug.WriteLine(String.Format("{0} Owner {1} Domain {2}", mo("Name"),
arOwner(0), arOwner(1)))

Next

Ken

-------------------

"Scott Meddows" <sc******************@tsged-removeme.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Can you tell who owns a running process in .NET?

I can do the system.diagnostic.process object and see if an application of the same name is running but I need to tell if the process is running by a current user or by another user.

Anyone know how to do this?

Thanks


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by sneffe | last post: by
24 posts views Thread by Sathyaish | last post: by
4 posts views Thread by commander_coder | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.