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:
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.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
Last edited by Leith Ross; 05-24-2011 at 04:15 PM. Reason: Added Code Tags
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks