Is there a simple way to get the names of all the user names of a local Windows 7 machine using .Net? So if I had a machine named MyPC, and it had 3 users MyPC\Mike, MyPC\Bob, and MyPC\Steve, I'd just want to be able to query to get Mike, Bob, and Steve. Of course, I don't care if they have the computer name attached, or not, as well.
+2
A:
If no-one comes up with a better way, you could enumerate the \Users folder and use the folders in there as representations. (Providing each user has logged in and the network isn't using roaming profiles)
Program.X
2010-02-19 19:48:14
Thank you. That does what I want it to do, only the results aren't exactly what I'd expect. My PC has only one user account, Mike, which is an administrator, and I have guests turned off. Yet when I run this: SelectQuery("Win32_UserAccount","Domain='Mike-PC'"), I get three results: Administrator, Mike, and Guest. I would expect to get only Mike. Are Administrator and Guest present by default?
Mike Pateras
2010-02-19 20:13:08