Hello,
Using this sample code from MSDN, I would like to get the username of
processes which is started conform the WMI query.
I am not able to get username when calling GetOwner method of
ROOT.CIMV2.Process .
I know it would be something like this, but when I put in in the
EventHandler the function returns 0 which is correct but no
Username !!
App.ROOT.CIMV2.Process wmiProcess = new App.ROOT.CIMV2.Process(
(System.Management.ManagementBaseObject)e.NewEvent["TargetInstance"]);
and then: wmiProcess.GetOwner(out domain, out user); --does not
work.
Pleeease can anyone help me with this ??????
I have tried a lot but I am quite new to dotnet/WMI.
Thank you in advance
Anna
/////// sample code
using System;
using System.Management;
public class EventWatcherAsync
{
public static int Main(string[] args)
{
WqlEventQuery query =
new WqlEventQuery("__InstanceCreationEvent",
new TimeSpan(0, 0, 1),
"TargetInstance isa \"Win32_Process\"");
ManagementEventWatcher watcher = new
ManagementEventWatcher(query);
watcher.EventArrived +=
new EventArrivedEventHandler((new
EventHandler()).HandleEvent);
watcher.Start();
System.Threading.Thread.Sleep(50000);
// Stop listening
watcher.Stop();
return 0;
}
}
public class EventHandler
{
public void HandleEvent(object sender, EventArrivedEventArgs e)
{
Console.WriteLine("Process has been created");
}
} 2 8108
you asked the question i wanted to. but it see no answers have come forward.
so i searched on the web and found this article and have yet digested. maybe
this will help you: http://www.codeproject.com/useritems...ssownersid.asp
"How to get process owner ID and current user SID"
"an***********@hotmail.com" wrote:
Hello,
Using this sample code from MSDN, I would like to get the username of
processes which is started conform the WMI query.
I am not able to get username when calling GetOwner method of
ROOT.CIMV2.Process .
I know it would be something like this, but when I put in in the
EventHandler the function returns 0 which is correct but no
Username !!
App.ROOT.CIMV2.Process wmiProcess = new App.ROOT.CIMV2.Process(
(System.Management.ManagementBaseObject)e.NewEvent["TargetInstance"]);
and then: wmiProcess.GetOwner(out domain, out user); --does not
work.
Pleeease can anyone help me with this ??????
I have tried a lot but I am quite new to dotnet/WMI.
Thank you in advance
Anna
/////// sample code
using System;
using System.Management;
public class EventWatcherAsync
{
public static int Main(string[] args)
{
WqlEventQuery query =
new WqlEventQuery("__InstanceCreationEvent",
new TimeSpan(0, 0, 1),
"TargetInstance isa \"Win32_Process\"");
ManagementEventWatcher watcher = new
ManagementEventWatcher(query);
watcher.EventArrived +=
new EventArrivedEventHandler((new
EventHandler()).HandleEvent);
watcher.Start();
System.Threading.Thread.Sleep(50000);
// Stop listening
watcher.Stop();
return 0;
}
}
public class EventHandler
{
public void HandleEvent(object sender, EventArrivedEventArgs e)
{
Console.WriteLine("Process has been created");
}
}
On Feb 20, 7:20 am, auldh <a...@discussions.microsoft.comwrote:
you asked the question i wanted to. but it see no answers have come forward.
so i searched on the web and found this article and have yet digested. maybe
this will help you:http://www.codeproject.com/useritems...ssownersid.asp
"How to get process owner ID and current user SID"
yes, thank you ! I have found it too and is working perfectly !
Greetings
Anna This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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
|
by: Rasta |
last post by:
Hi, I've created a new table in a SQL Server db called 'LGBProdDetails' and
I keep getting an error from my asp page that queries the table The error
is:
Category=Microsoft OLE DB Provider for...
|
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
|
by: news.microsoft.com |
last post by:
I need to find a way to run an external exe (using the process class I
assume) and hide. When the process is closed I want my application to
reappear.
For example, press a button on form1, run...
|
by: Moses M |
last post by:
I posted this a short while ago , but I don't think I explained the problem
clearly. Task Manager lists processes running on a local system, including a
"user name" associated with each process...
|
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...
|
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:
...
|
by: Bob Allen |
last post by:
i am using the following code and it works great in a terminal service
environment until i log in as a non-admin.
if i log in as an admin it works fine but otherwise i get a null returned
from the...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |