Hi
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 = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
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.ReferencedDomainNam e & "\" & acct.AccountName)
End If
Next
(CheckedListBox1 is added by me in stead of WScript.echo.)
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 = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
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.ReferencedDomainNam e & "\" & acct.AccountName)
End If
Next
(CheckedListBox1 is added by me in stead of WScript.echo.)