Returns a list of logon scripts displayed on a per-Group Policy Object (GPO) basis. Script contributed by Microsoft's Mike Stephens and Judith Herman.

Visual Basic
Edit|Remove
Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "Software\Policies\Microsoft\Windows\System\Scripts\Logon"
oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys
 
For Each subkey In arrSubKeys
    strValueName  = "DisplayName"
    strGUIDVName  = "GPOName"
    strFullKeyPath = strKeyPath & "\" & subkey
    oReg.GetStringValue HKEY_CURRENT_USER, strFullKeyPath, strValueName, szValue 
    oReg.GetStringValue HKEY_CURRENT_USER, strFullKeyPath, strGUIDVName, szGPOName 
    wScript.Echo "Name and GUID of GPO deploying logon Script = " & szValue & _
        "    " & szGPOName

    oReg.EnumKey HKEY_CURRENT_USER, strFullKeyPath, arrGPOSubKeys
    For Each Scriptsubkey in arrGPOSubkeys
        ' Script and parameters under subkeys
        strScript = "Script"
        strParam  = "Parameters"
        strScriptKeyPath = strFullKeyPath & "\" & Scriptsubkey
        oReg.GetStringValue HKEY_CURRENT_USER, strScriptKeyPath, strScript, szScript 
        oReg.GetStringValue HKEY_CURRENT_USER, strScriptKeyPath, strParam,  szParam 
        wScript.Echo "   Logon script = " & szScript
        wScript.Echo "   Script Parameters = " & szParam
        wScript.Echo "    "
    Next
Next