Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Now that I have the c#-script running that returns the all the windows users. Some clarifications is needed please. It does return all the Windows users names. 8 to be exact. There should only be 4, user1, user2, user3, user4. It also returns names like
"administrator", defaultaccount, defaultuser1, and last: "WDagutilityaccount"; which I don't really know why it returns these 4. Is there some clarifications that I put on that it only returns the four(4) usernames only??? There's a little of bit of behind the senses that's not documented that gets 'using system.management' going. But any rate, I just want the usernames only, not these other junknames. Any insights sure would be helpful.
Thanks,

Some sentence corrections.

What I have tried:

I'm using this script:

C#
            ///            ManagementScope mgmtScope = new ManagementScope("\\\\.\\Root\\CIMv2");
            ObjectQuery oQuery = new ObjectQuery("SELECT * FROM Win32_UserAccount");   ////  Where Name=\"myUserName\"");
            ManagementObjectSearcher mgmtSearch = new ManagementObjectSearcher(oQuery);  //// (mgmtScope, oQuery);
            ManagementObjectCollection objCollection = mgmtSearch.Get();
            foreach (ManagementObject mgmtObject in objCollection)
================
Posted
Updated 24-Dec-20 19:46pm
v4

1 solution

Because they are users on your machine.
For example, the WDAGUtilityAccount is part of Windows Defender, and so on.
Install more software, and you may accumulate other accounts.
 
Share this answer
 
Comments
Member 15028314 25-Dec-20 12:14pm    
OK. But, isn't there some clarifying switch(that exists) that tells whether it's an installed package or a valid user. There's got to be one; it can't let you hang like this. Any examples???
Dave Kreskowiak 27-Dec-20 1:16am    
They are not "installed packages". They are actual user accounts, no different than your own.

Applications run as the account that launches them, even accounts that don't have a flesh and blood user logging into them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900