Hi,
I'm trying to get all the users state or status, not sure what is the property name.
I found this code for the userName property:
ConnectionOptions options = new ConnectionOptions();
options.EnablePrivileges = true;
ManagementScope scope = new ManagementScope("\\\\" + fqdn + "\\root\\CIMV2", options);
scope.Connect();
SelectQuery query = new SelectQuery("Win32_ComputerSystem");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope, query);
string machineUser = "";
foreach (ManagementObject os in searcher.Get())
{
machineUser +=" "+ os.GetPropertyValue("username").ToString();
}
I would like to also have the user state, if the user is on sleep, inactive, active etc.
Where can I find it?
Thanks in advance :-)
------
one more thing, when no user is logged on
os.GetPropertyValue("username").ToString();
throws an exception.
Is that the expected behavior? How can I tell if that's the reason or it's something else?
If I could just have the users and their status, that would have been great :-)