Im developing a winforms wizard and in one page of this wizard i need to list all the accounts to enable the user select one. So my working code is:
private static IEnumerable<string> GetUsersAccountName()
{
var searcher = new ManagementObjectSearcher(new SelectQuery("Win32_UserAccount"));
var usersAccounts = (from ManagementBaseObject envVar in searcher.Get()
select envVar["Name"].ToString());
return users.ToList();
}
So with this method i get the name of the accounts, but not get the "local system account", how to get this account name too?