Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Get the user names and domains of all locally stored user profi

samohtrelhesamohtrelhe Posts: 2Member
I'd like to retrieve the user names and domains of all user profiles stored on a computer, through WMI, using VB.NET?
The Code below does exactly what I need, but in VBScript.
How can I convert it to VB.NET?
(I do not want to use "Win32_UserAccount" :-)

Const HKLM = &H80000002
Const profiles = "SOFTWAREMicrosoftWindows NTCurrentVersionProfileList"

sh = CreateObject("WScript.Shell")
fso = CreateObject("Scripting.FileSystemObject")
wmi = GetObject("winmgmts://./root/cimv2")
reg = GetObject("winmgmts://./root/default:StdRegProv")

reg.EnumKey(HKLM, profiles, subkeys)
For Each sid In subkeys
reg.GetStringValue(HKLM, profiles & "" & sid, "ProfileImagePath", path)
path = sh.ExpandEnvironmentStrings(path)
If fso.FolderExists(path) Then
acct = wmi.Get("Win32_SID.SID='" & sid & "'")
CheckedListBox1.Items.Add(acct.ReferencedDomainName & "" & acct.AccountName)
End If

(CheckedListBox1 is added by me in stead of WScript.echo.)


Sign In or Register to comment.