有没有办法将HKEY_USERS下的值连接到实际的用户名?
我看到了一些类似的问题,但大多数(如果不是全部的话)谈论C#代码,而我的需求是在VBScript中。
如果您查看以下任一键:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\hivelist
你可以在那里找到各种值的SID列表,包括他们的“主路径”,包括他们的用户名。
我不确定这是多么可靠,我不会推荐搞这个,除非你真的确定你在做什么。
可以从WMI查询这些信息。 以下命令将为每个用户输出一个带有行的表格以及每个用户的SID。
wmic useraccount get name,sid
您也可以将此信息导出为CSV:
wmic useraccount get name,sid /format:csv > output.csv
我已经在Vista和7上使用过。有关更多信息,请参阅WMIC – 通过WMI进行命令行控制 。
打开注册表HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ ProfileList \
做一个循环来获取所有的子项
你感兴趣的子键是那些以[S-1-5-21-]表示的用户(见键名[ProfileImagePath],它们总是以路径c:\ Users开始的)
以[S-1-5-21-12]开头的都是本地用户
以[S-1-5-21-13]开头的所有网络用户( 如果连接到Domained网络 )都是以前登录在机器上的网络用户。
您可以使用微软SysInternals团队的命令PSGetSid。
下载网址: http : //technet.microsoft.com/en-gb/sysinternals/bb897417.aspx
用法:
psgetsid [\\computer[,computer[,...] | @file] [-u username [-p password]]] [account|SID] -u Specifies optional user name for login to remote computer. -p Specifies optional password for user name. If you omit this you will be prompted to enter a hidden password. Account PsGetSid will report the SID for the specified user account rather than the computer. SID PsGetSid will report the account for the specified SID. Computer Direct PsGetSid to perform the command on the remote computer or computers specified. If you omit the computer name PsGetSid runs the command on the local system, and if you specify a wildcard (\\*), PsGetSid runs the command on all computers in the current domain. @file PsGetSid will execute the command on each of the computers listed in the file.
例:
psgetsid S-1-5-21-583907252-682003330-839522115-63941
注意:
更新
如果您使用PowerShell,以下可能会有助于解决列出的任何AD用户:
#create a drive for HKEY USERS: New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS -ErrorAction SilentlyContinue #List all immediate subfolders #where they're a folder (not a key) #and they's an SID (ie exclude .DEFAULT and SID_Classes entries) #return the SID #and return the related AD entry (should one exist). Get-ChildItem -Path 'HKU:\' ` | ?{($_.PSIsContainer -eq $true) ` -and ($_.PSChildName -match '^S-[\d-]+$')} ` | select @{N='SID';E={$_.PSChildName}} ` , @{N='Name';E={Get-ADUser $_.PSChildName | select -expand Name}}
您还可以进一步细化SID过滤器,只将需要解析的SID撤回到AD帐户; 更多关于这里的SID结构: https : //technet.microsoft.com/en-us/library/cc962011.aspx
通过在注册表中搜索我的用户名,我发现
HKEY_CURRENT_USER\Volatile Environment\Username
完成它,通过一些创意编程,
枚举键HKEY_USERS这些有趣的数字键…
在HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ ProfileList \
你会发现相同的数字….现在在这些键看字符串值:ProfileImagePath =“SomeValue”其中的值是:
“%systemroot%\ system32 \ config \ systemprofile”…对这个不感兴趣…因为它不是一个目录路径…
%SystemDrive%\ Documents and Settings \ LocalService – “本地服务”%SystemDrive%\ Documents and Settings \ NetworkService“NETWORK SERVICE”
要么
%SystemDrive%\ Documents and Settings \ USER_NAME,它可以直接转换为大多数未被篡改的系统中的“USERNAME”值。 用户在几个星期后还没有更改他们的用户名或明确地更改路径…
for /f "tokens=8 delims=\" %a in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\hivelist" ^| find "UsrClass.dat"') do echo %a