Click here to Skip to main content
13,048,011 members (73,599 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 2:30am
CHill60 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 13 Mar 2013
Copyright © CodeProject, 1999-2017
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