operating system accounts(to login) in vb.net
-
I am using the following code to list the accounts of my operating system. Currently i have just two accounts namely 1.Administator 2.Guest But it shows 6 accounts. can i filter the query to make it to show the actual accounts.
Dim oQuery As New Management.ObjectQuery("select * from Win32_Account WHERE SIDType = 1") Dim osearch As New ManagementObjectSearcher(oQuery) Dim ocollection As ManagementObjectCollection = osearch.Get Dim oresult As ManagementObject For Each oresult In ocollection TextBox1.Text = oresult("Name").ToString & " " Next
Thank You Pankaj -
I am using the following code to list the accounts of my operating system. Currently i have just two accounts namely 1.Administator 2.Guest But it shows 6 accounts. can i filter the query to make it to show the actual accounts.
Dim oQuery As New Management.ObjectQuery("select * from Win32_Account WHERE SIDType = 1") Dim osearch As New ManagementObjectSearcher(oQuery) Dim ocollection As ManagementObjectCollection = osearch.Get Dim oresult As ManagementObject For Each oresult In ocollection TextBox1.Text = oresult("Name").ToString & " " Next
Thank You PankajI think it is showing the real accounts, with the `hidden` accounts, such as the help and support account, if you have VMWare installed, __vmware_user__ and other things. You could try:
For Each oresult In ocollection
Dim oname As String = oresult("Name").ToString
If Not oname.StartsWith("SUPPORT") Then
If oname <> "__vmware_user__" Then
If oname <> "ASPNET" Then
If oname <> "HelpAssistant" Then
textBox1.Text = oname & " "
End If
End If
End If
End IfI don't know if this'll work very well.