Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Make sure to have WMI installed or enabled on your PC, also make sure to add a reference to <code>System.Management</code> and <code>System.Management.Instrumentation</code> as well. There is also a C# and VB WMI scripting application GUI that you can download to run and test WMI Queries against as well Google that one. Since I work for Dept of Defense there are certain things that I can get to from here in regards to the web other things are blocked out so please forgive me if I don't post certain web links.</p> <p>Here is something to get you started </p> <pre><code> ManagementScope mgtScope = new ManagementScope("\\\\ComputerName\\root\\cimv2"); // you could also replace the username in the select with * to query all objects ObjectQuery objQuery = new ObjectQuery("SELECT username FROM Win32_ComputerSystem"); ManagementObjectSearcher srcSearcher = new ManagementObjectSearcher(mgtScope, objQuery); ManagementObjectCollection colCollection = srcSearcher.Get(); foreach (ManagementObject curObjCurObject in colCollection) { Console.WriteLine(curObjCurObject["username"].ToString()); } //if you want ot get the name of the machine that changed it once it gets into that Event change the query to look like this. I just tested this locally and it does work ManagementObjectSearcher mosQuery = new ManagementObjectSearcher("SELECT * FROM Win32_Process WHERE ProcessId = " + Process.GetCurrentProcess().Id.ToString()); ManagementObjectCollection queryCollection1 = mosQuery.Get(); foreach (ManagementObject manObject in queryCollection1) { Console.WriteLine("Name : " + manObject["name"].ToString()); Console.WriteLine("Version : " + manObject["version"].ToString()); Console.WriteLine("Manufacturer : " + manObject["Manufacturer"].ToString()); Console.WriteLine("Computer Name : " + manObject["csname"].ToString()); Console.WriteLine("Windows Directory : " + manObject["WindowsDirectory"].ToString()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload