Results 1 to 1 of 1

Using VBA and WMI to read registry

Threaded View

badducchio Using VBA and WMI to read... 05-24-2011, 04:10 PM
  1. #1
    Registered User
    Join Date
    05-24-2011
    Location
    Ohio
    MS-Off Ver
    Excel 2003
    Posts
    1

    Using VBA and WMI to read registry

    I am leveraging WMI via VBA in Excel 2010 to read the registry and write it to a cell. The code works on similar items but I am having issues reading a WSUS value. The code works in a stand alone vb script but not in excel. Code:
    Sub Test()
    
    Const HKEY_LOCAL_MACHINE = &H80000002
    
    strComputer = "."
    Set objPatch = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
    
    strPatchKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install"
    strPatchEntry = "LastSuccessTime"
    
    objPatch.GetStringValue HKEY_LOCAL_MACHINE, strPatchKeyPath, strPatchEntry, strPatchDate
    
    Cells(1, 1) = strPatchKeyPath & "\" & strPatchEntry & " = " & strPatchDate
    
    End Sub
    The value is returned as Null. I can manually read the value in the registry and it works through the VB script using wscript. Any help would be appreciated.
    Last edited by Leith Ross; 05-24-2011 at 04:15 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1