[Message Deleted]
-
you can try using the WMI C# code generator, refer to link: http://veeralp.blogspot.com/2007/11/wmi-code-generation-for-c-vbnetvb.html[^] WMI is not that hard to learn, there is alot of information available on MSDN. If you have any more problems post back.
-
you can try using the WMI C# code generator, refer to link: http://veeralp.blogspot.com/2007/11/wmi-code-generation-for-c-vbnetvb.html[^] WMI is not that hard to learn, there is alot of information available on MSDN. If you have any more problems post back.
I've been using the WMI code generator to get my start, but I'm having trouble figuring out how to implement WMI in C# on my own. I've figured out that what I'll probably do to check who is logged on the computer remotly is use: -Win32_Process, filter where name='explorer.exe' And then: -GetOwner to throw back the username. Are u familiar on how to implement WMI in C#? I could really use a hand.
-
I've been using the WMI code generator to get my start, but I'm having trouble figuring out how to implement WMI in C# on my own. I've figured out that what I'll probably do to check who is logged on the computer remotly is use: -Win32_Process, filter where name='explorer.exe' And then: -GetOwner to throw back the username. Are u familiar on how to implement WMI in C#? I could really use a hand.
try this. I got the code snippet from the code generator itself. However, makesure you know which Win32_Process.Handle you want t10execute GetOwner on. In the code snippet its tied to 1076. using System; using System.Management; using System.Windows.Forms; namespace WMISample { public class CallWMIMethod { public static void Main() { try { ManagementObject classInstance = new ManagementObject("root\\CIMV2", "Win32_Process.Handle='1076'", null); // no method in-parameters to define // Execute the method and obtain the return values. ManagementBaseObject outParams = classInstance.InvokeMethod("GetOwner", null, null); // List outParams Console.WriteLine("Out parameters:"); Console.WriteLine("Domain: " + outParams["Domain"]); Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]); Console.WriteLine("User: " + outParams["User"]); } catch(ManagementException err) { MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message); } } } }