Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
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
Next


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

Samoht
Posted
Comments
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 VB.net but have to ad the fuctionality of the above to an existing form.

1 solution

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 http://www.dreamincode.net/forums/topic/31219-working-with-the-windows-registry-in-vbnet/[^]
The official Microsoft stuff is here http://msdn.microsoft.com/en-us/library/aa289494(v=vs.71).aspx[^]
Have a go with these examples and come back if you then have a specific issue
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900