Need vbscript to get current user ID during logoff and login
Hi,
Any body help me in creating vb script.
I need to create SID key under my application related key which has shown like below:
HKLM\Software\ABC\XYZ\SID
So during logoff and login through stubpath i need to call the vb script which should get the current logged in user SID, so that i can create the SID key under my application related key. This should happen for every user. So I am calling this in active setup.
Thanks
Sanhivi
Answers (4)
I don't think so, you can achive this using ActiveSetup without giving permission.. because you are trying to create keys under HKLM through ActiveSetup.. When you try to create HKLM key through ActiveSetup, you will receive Access Denied error..
It will work only for Local Admins/Admin account, not for the standard users
Comments:
-
You could modify the keyset permissions with regini and give local users rights to that particular key and then try active setup.
http://support.microsoft.com/kb/237607 - SMal.tmcc 12 years ago -
Yes.. Correct.. You will have to give Full Control to the User group for HKLM\Software\ABC\XYZ\ - jagadeish 12 years ago
-
May I know the reason for storing SID's in HKLM hive? - jagadeish 12 years ago
-
The $54 question - SMal.tmcc 12 years ago
This should work for you with bit of modifications....
Dim WshShell: Set WshShell = CreateObject("WScript.Shell")
Dim oReg,strHKCU
Dim strKeyParent
Dim ret
Dim strKeyName
Dim arrSubKeys
Dim strAppDataChk
Dim ConfigIni,ConfigXml
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_USERS = &H80000003
Set ObjFSO=CreateObject("Scripting.filesyStemObject")
strComputerName = "."
On Error Resume Next
Set oReg=GetObject("winmgmts:root\default:StdRegProv")
strKeyParent = ""
ret = oReg.EnumKey(HKEY_USERS, strKeyParent, arrSubKeys)
oReg.EnumKey HKEY_USERS, strKeyParent, arrSubKeys
If NOT IsNull(arrSubKeys) Then
For i=0 To UBound(arrSubKeys)
strGUID = arrSubKeys(i)
If Len(strGUID) > 17 AND NOT Right(strGUID,8) = "_Classes" Then
strAppDataChk = WshShell.RegRead("HKEY_USERS\" & strGUID & "\Volatile Environment\APPDATA")
If strAppDataChk<>"" Then
strHKCU=strGUID
msgbox strHKCU
end if
End If
Next
End If
Comments:
-
Sumit.. Should we use strHKCU, outside the loop.. is it? - jagadeish 12 years ago
-
Yes ,use this outside the loop :) - sumitsingh1984 12 years ago