vbscript для WiX

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
'Поиск в SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
'ветки пользователя с именем, заданным в USERNAME
'и запись найденного SID'а в USERSID.
Function GetSID()
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
subStr = Split(strValue,"\")
username = subStr(UBound(subStr))
If StrComp(username,Session.Property("USERNAME")) = 0 Then
Session.Property("USERSID") = objSubkey
End If
Next
GetSID = 0
End Function