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.
Bookmarks