/build/static/layout/Breadcrumb_cap_w.png

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


0 Comments   [ + ] Show comments

Answers (4)

Posted by: jagadeish 12 years ago
Red Belt
1

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
Posted by: piyushnasa 12 years ago
Red Belt
1

You will have to take care the SID is different for all the users. This SID would be pointing to one of the user and you should try to map it to the HKCU key. Then use Active Setup or Advertised shortcut to get this registry for all the users.

Posted by: sumitsingh1984 12 years ago
Second Degree Green Belt
0

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

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ