Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB VB.NET
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 13-Mar-13 3:30am
Comments
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 VB.net but have to ad the fuctionality of the above to an existing form.

1 solution

Rate this: bad
good
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 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
  Permalink  

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

  Print Answers RSS
0 Mathew Soji 309
1 BillWoodruff 300
2 Afzaal Ahmad Zeeshan 252
3 DamithSL 225
4 Maciej Los 215
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 13 Mar 2013
Copyright © CodeProject, 1999-2014
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