Assuming you're trying to replicate the list shown on the Windows lock screen, it's not as simple as passing a filter to the list.
By default, Windows will show all enabled local user accounts on the lock screen, assuming the computer is not joined to an AD domain.
But you can override that via the registry:
For specifically hiding an account from login screen, use registry:
- Go to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
. - Create
SpecialAccounts
sub-key to Winlogon
. Then create UserList
sub-key to SpecialAccounts
. - So at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList
, at the right pane create DWORD
value with name of user account name you want to hide. - Set the
DWORD
value data to 0
.
That means your code will need to query the registry to see if any accounts are hidden from the lock screen, as well as checking that the account is enabled.
To further complicate matters, there's a group policy setting to make Windows show the local users list even if the computer is joined to a domain.
(Computer Configuration ⇒ Administrative Templates ⇒ System ⇒ Logon ⇒ Enumerate local users on domain-joined computers)
And the lock screen will also show any users who are currently logged in to the computer, whether they are local or domain users.