VB.NET从SID访问并解析ReferencedDomainName和AccountName [英] VB.NET Access and resolve ReferencedDomainName and AccountName from SID
问题描述
嗨
我非常想完成以下脚本所做的事,就在VB内部!
Const HKLM =& h80000002
Const profiles =SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
Set sh = CreateObject (WScript.Shell)
设置fso = CreateObject(Scripting.FileSystemObject)
设置wmi = GetObject(winmgmts://./root/cimv2)
设置reg = GetObject(winmgmts://./root/default:StdRegProv)
reg.EnumKey HKLM,profile,subkeys
For each sid In subkeys
reg.GetStringValue HKLM,简介& \& sid,ProfileImagePath,路径
path = sh.ExpandEnvironmentStrings(path)
如果fso.FolderExists(path)那么
设置acct = wmi.Get(Win32_SID.SID ='' & sid&'')
WScript.Echo acct.ReferencedDomainName& \& acct.AccountName
结束如果
下一步
只需通过ProfileList中的SID键并拉出
ReferencedDomainName& \&账户名
我相信你们中的一些人会发现它很微不足道,但我无法让它发挥作用: - /
亲切的问候和寄予厚望
Samoht
< blockquote>看看这个代码项目文章使用VB使用Windows注册表。 NET [ ^ ]不幸的是它已经很老了但可能足以让你前进。
这里有一个稍微更近的(!)教程http://www.dreamincode.net/forums/topic/31219-working-with-the -windows-registry-in-vbnet / [ ^ ]
微软的官方资料在这里 http://msdn.microsoft.com/en-us/library/aa289494(v = vs.71)的.aspx [<一个href =http://msdn.microsoft.com/en-us/library/aa289494(v=vs.71).aspx\"target =_ blanktitle =New Window> ^ ]
如果您有特定问题,请查看这些示例并返回
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
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
这篇关于VB.NET从SID访问并解析ReferencedDomainName和AccountName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!