2011-11-02 75 views
0

我正在尝试为我管理的AD成员创建用户帐户信息报告。具体而言,我需要在Outlook安装中配置哪些帐户;他们使用什么类型的协议(POP/IMAP)以及为备份目的存储关联的PST文件在哪里。我认为我可以在可以写入共享位置的文件的所有机器上部署VBScript,然后我可以检索该文件。 我发现了一些在线脚本,它可以在HKCU .. \ Windows Messaging Subsystem \ Profiles中找到PST文件位置,但无法理解它们如何解析十六进制密钥。如果我能弄清楚,我可能会获得存储在子项上的其他信息。 任何帮助解决这个将不胜感激。如何使用VBScript查找Registry帐户中的Outlook帐户信息?

回答

0

终于在网上用指针指出了它。这基本上从指定的子项循环到注册表中的三个级别,并将其写入文件。

const HKCU = &H80000001 
Const REG_SZ  = 1 
Const REG_EXPAND_SZ = 2 
Const REG_BINARY = 3 
Const REG_DWORD  = 4 
Const REG_MULTI_SZ = 7 
strComputer = "." 
Set StdOut = WScript.StdOut 
Dim objFSO :Set objFSO = CreateObject("Scripting.FileSystemObject") 
Dim objPSTLog :Set objPSTLog = objFSO.OpenTextFile("%temp%\pst.log",8,True) 

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv") 

strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" 
oReg.EnumKey HKCU, strKeyPath, arrSubKeys 

For Each subkey In arrSubKeys 
    objPSTLog.WriteLine(subkey) 
    strkeyPath1 = strkeyPath & subkey 'Outlook 
    oReg.EnumKey HKCU, strKeyPath1, arrSubKeys1 
    if IsArray(arrSubKeys1) Then 
     For Each subkey1 In arrSubKeys1 
      strkeyPath2 = strkeyPath1 & "\" & subkey1 'Outlook\8bce72417aa40d418ab879690e9b39cc etc 
      oReg.EnumKey HKCU, strKeyPath2, arrSubKeys2 
      if IsArray(arrSubKeys2) Then 
       For Each subkey2 In arrSubKeys2 
        objPSTLog.WriteLine(subkey2) 
        strkeyPath3 = strkeyPath2 & "\" & subkey2 'Outlook\8bce72417aa40d418ab879690e9b39cc\0000001 etc 
        oReg.EnumValues HKCU, strKeyPath3, arrValueNames, arrTypes 
        if IsArray(arrValueNames) Then 
         For i = lBound(arrValueNames) To uBound(arrValueNames) 
          strValueName = arrValueNames(i) 
          Select Case arrTypes(i) 

           ' Show a REG_SZ value 
           ' 
           Case REG_SZ   
           oReg.GetStringValue HKCU, strKeyPath3, strValueName, strValue 
           objPSTLog.WriteLine(" " & strValueName & " (REG_SZ) = " & strValue) 

           ' Show a REG_EXPAND_SZ value 
           ' 
           Case REG_EXPAND_SZ 
           oReg.GetExpandedStringValue HKCU, strKeyPath3, strValueName, strValue 
           objPSTLog.WriteLine(" " & strValueName & " (REG_EXPAND_SZ) = " & strValue) 

           ' Show a REG_BINARY value 
           '   
           Case REG_BINARY 
           oReg.GetBinaryValue HKCU, strKeyPath3, strValueName, arrBytes 
           strBytes = "" 
           For Each uByte in arrBytes 
            uByte = Hex(uByte) 
            strBytes = strBytes & uByte & " " 
           Next 
           objPSTLog.WriteLine(" " & strValueName & " (REG_BINARY) = " & strBytes) 

           ' Show a REG_DWORD value 
           ' 
           Case REG_DWORD 
           oReg.GetDWORDValue HKCU, strKeyPath3, strValueName, uValue 
           objPSTLog.WriteLine(" " & strValueName & " (REG_DWORD) = " & CStr(uValue)) 

           ' Show a REG_MULTI_SZ value 
           ' 
           Case REG_MULTI_SZ 
           oReg.GetMultiStringValue HKCU, strKeyPath3, strValueName, arrValues        
           objPSTLog.WriteLine(" " & strValueName & " (REG_MULTI_SZ) =") 
           For Each strValue in arrValues 
            objPSTLog.WriteLine(" " & strValue) 
           Next 
          End Select 
         Next 
        End If 
        strKeyPath3="" 
       Next 
      End If 
      strKeyPath2="" 
     Next 
     strkeyPath1 = "" 
    End If 
Next 


objPSTLog.WriteLine("") 
objPSTLog.WriteLine("--------------------------------------------------------------------------------------------------------------") 
objPSTLog.WriteLine("") 
objPSTLog.close 

MsgBox "Script Run Successful" 

它仍然写入十六进制值。 PST位置存储在“Delivery Store EntryID”,帐户名称和电子邮件中的“帐户名称”&“电子邮件”中。全部存储为REG_BINARY。 如何在最后一个循环中的REG_BINARY大小写中获得ASCII输出?