Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: VB VB.NET
I'd very much like to do exactly what the following script does, just from inside VB!
Const HKLM = &h80000002
Const profiles = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
Set sh  = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set wmi = GetObject("winmgmts://./root/cimv2")
Set 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
    Set acct = wmi.Get("Win32_SID.SID='" & sid & "'")
    WScript.Echo acct.ReferencedDomainName & "\" & acct.AccountName
  End If
JUST go through the SID keys in ProfileList and pull out the
ReferencedDomainName & "\" & Accountname
I'm sure some of you guys will find it trivial but I cannot make it work :-/
With Kind regards and high hopes
Posted 13-Mar-13 3:30am
CHill60 at 13-Mar-13 8:32am
When you say you cannot make it work, what is the problem you encounter? Use the Improve Question link above to post the VB code you are having the problem with.
samoht relhe at 13-Mar-13 8:50am
Uhm. More or less it all.. how to get hold of the subkeys and read them and how to declare the needed objects..
I am not normally using but have to ad the fuctionality of the above to an existing form.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Have a look at this codeproject article Working with Windows Registry using VB.NET[^] Unfortunately it's quite old but may be enough to get you going.
There is a slightly more recent (!) tutorial here[^]
The official Microsoft stuff is here[^]
Have a go with these examples and come back if you then have a specific issue

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 645
1 Maciej Los 225
2 Abhinav S 171
3 Richard Deeming 160
4 Suvendu Shekhar Giri 159
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 9,135
2 Peter Leow 5,042
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,581

Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 13 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100