8 Replies - 4510 Views - Last Post: 09 June 2012 - 01:56 AM Rate Topic: -----

#1 shie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 22-January 11

how to display all user accounts on a listbox using vb2010?

Posted 22 January 2011 - 09:27 PM

hi! i just started using vb2010 and i am working on a project wherein i want to display all the computer user accounts on a list box..is there anyone there who can help me?? thanks a lot! :)
Is This A Good Question/Topic? 0
  • +

Replies To: how to display all user accounts on a listbox using vb2010?

#2 qtex  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 142
  • Joined: 24-October 09

Re: how to display all user accounts on a listbox using vb2010?

Posted 23 January 2011 - 06:35 AM

As I saw solution for it was here : Click Here !
Please don't use so big font, its not good to read it.
Was This Post Helpful? 0
  • +
  • -

#3 thenegro900  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 17-January 11

Re: how to display all user accounts on a listbox using vb2010?

Posted 23 January 2011 - 07:36 AM

That is very easy thing to do
 Dim _RegistryKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList")
		For Each _KeyName As String In _RegistryKey.GetSubKeyNames()
			Using SubKey As RegistryKey = _RegistryKey.OpenSubKey(_KeyName)
				Dim _Users,_Username As String 
                               _Users= DirectCast(SubKey.GetValue("ProfileImagePath"), String)
                               _Username = System.IO.Path.GetFileNameWithoutExtension(_Users)
				ListBox1.Items.Add(_Username)
			End Using
		Next



Give me a + if you find the code working on was this post helpful section, just below this post
Was This Post Helpful? 0
  • +
  • -

#4 shie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 22-January 11

Re: how to display all user accounts on a listbox using vb2010?

Posted 24 January 2011 - 07:13 AM

View Postqtex, on 23 January 2011 - 06:35 AM, said:

As I saw solution for it was here : Click Here !
Please don't use so big font, its not good to read it.



I already read that post. but it seems that it does not perfectly work. It also display the Network Service, Local Service and systemprofile as well. How do i avoid getting those system logins?

..and sorry for using big font. :)
Was This Post Helpful? 0
  • +
  • -

#5 shie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 22-January 11

Re: how to display all user accounts on a listbox using vb2010?

Posted 24 January 2011 - 07:18 AM

View Postthenegro900, on 23 January 2011 - 07:36 AM, said:

That is very easy thing to do
 Dim _RegistryKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList")
		For Each _KeyName As String In _RegistryKey.GetSubKeyNames()
			Using SubKey As RegistryKey = _RegistryKey.OpenSubKey(_KeyName)
				Dim _Users,_Username As String 
                               _Users= DirectCast(SubKey.GetValue("ProfileImagePath"), String)
                               _Username = System.IO.Path.GetFileNameWithoutExtension(_Users)
				ListBox1.Items.Add(_Username)
			End Using
		Next



Give me a + if you find the code working on was this post helpful section, just below this post


I already tried that code but I seem to get the Network Service, Local Service and systemprofile as well.
How do i avoid getting those system logins? Can you please help me? Thanks. :)
Was This Post Helpful? 0
  • +
  • -

#6 qtex  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 142
  • Joined: 24-October 09

Re: how to display all user accounts on a listbox using vb2010?

Posted 24 January 2011 - 08:18 AM

You can also try this code.

Dim _RegistryKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList")
        For Each _KeyName As String In _RegistryKey.GetSubKeyNames()
            Using SubKey As RegistryKey = _RegistryKey.OpenSubKey(_KeyName)
                Dim _Users, _Username As String
                _Users = DirectCast(SubKey.GetValue("ProfileImagePath"), String)
                _Username = System.IO.Path.GetFileNameWithoutExtension(_Users)
                ListBox1.Items.Add(_Username)
                ListBox1.Items.Remove("systemprofile")
                ListBox1.Items.Remove("LocalService")
                ListBox1.Items.Remove("NetworkService")
            End Using
        Next


Regards,
Qtex
Was This Post Helpful? 1
  • +
  • -

#7 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: how to display all user accounts on a listbox using vb2010?

Posted 24 January 2011 - 09:27 AM

I just answered another topic based on this same question.

See if this helps
Was This Post Helpful? 1
  • +
  • -

#8 shie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 22-January 11

Re: how to display all user accounts on a listbox using vb2010?

Posted 25 January 2011 - 10:43 PM

View Postqtex, on 24 January 2011 - 08:18 AM, said:

You can also try this code.

Dim _RegistryKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList")
        For Each _KeyName As String In _RegistryKey.GetSubKeyNames()
            Using SubKey As RegistryKey = _RegistryKey.OpenSubKey(_KeyName)
                Dim _Users, _Username As String
                _Users = DirectCast(SubKey.GetValue("ProfileImagePath"), String)
                _Username = System.IO.Path.GetFileNameWithoutExtension(_Users)
                ListBox1.Items.Add(_Username)
                ListBox1.Items.Remove("systemprofile")
                ListBox1.Items.Remove("LocalService")
                ListBox1.Items.Remove("NetworkService")
            End Using
        Next




Regards,
Qtex




its a very tricky code by means of using remove. but i really want to figure it out how can i avoid getting those logins without using "items.remove". but thanks anyway. :)

This post has been edited by shie: 25 January 2011 - 10:44 PM

Was This Post Helpful? 0
  • +
  • -

#9 Arne25  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-June 12

Re: how to display all user accounts on a listbox using vb2010?

Posted 09 June 2012 - 01:56 AM

View Postshie, on 22 January 2011 - 09:27 PM, said:

hi! i just started using vb2010 and i am working on a project wherein i want to display all the computer user accounts on a list box..is there anyone there who can help me?? thanks a lot! :)


Hey,

I found the answere.
At this sitethey give you the perfect solution. You get all local user accounts in a listbox.
The only thing you need to do is add the reference system.directoryservices.accountmanagement.dll

Greets
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1