Registry Date parsing

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
sysadmber
Posts: 50
Joined: Tue Dec 08, 2015 1:26 am

Registry Date parsing

Post by sysadmber »

Hello,

i hope you can help me with a registry test. I want to check whether the last Windows Update is not longer than 60 days.

The Registry Key (on Servers) is

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install\LastSuccessTime

Sample Result is: "2017-06-17 17:55:15"

In the doku i didn't find a variable for seconds so i'm unsure iof the string can currently parsed successful. I used the following Expression in the field "Alert when Value"

is > than

%yyyy-mm-dd %hh%:%nn%[-60d]%

What am i doing wrong?

Regards
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

"Alert when Value" is > than %yyyy-mm-dd %hh%:%nn%[-60d]%
What am i doing wrong?
Everything :-)
Should be "Alert when Value is < than %yyyy-mm-dd[-60d]%

Note: system "short date" format should be yyyy-mm-dd

Regards
Alex
sysadmber
Posts: 50
Joined: Tue Dec 08, 2015 1:26 am

Post by sysadmber »

Thanks.

The Reply fields shows always the value read from the registry. How can i show the result of the computation?

It should show "5 Days".
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I don't think this is possible unless you create your own shell script to check registry and return # of days to HostMonitor
e.g.

Code: Select all

'Checks date of last installed Windows update
'====================================================================
'Start cmd: cmd /c cscript /B /E:VBScript %Script% %Params%
'Script requires 1 parameter - number of days threshold.
'====================================================================
'www.ks-soft.net

Option Explicit

const statusOk          = "scriptRes:Ok:"
const statusBad         = "scriptRes:Bad:"
const statusUnknown     = "scriptRes:Unknown:"

Dim oWU, iTHCount, colUpdate, oUpdate, Cnt, k, Dat, objArgs, MDays

Dat = Date
Cnt = 9999999
k = 0
Set objArgs = WScript.Arguments

if objArgs.Count <> 1 then
WScript.StdOut.Write statusUnknown & "Parameter is required: <Max Days Count>"
WScript.Quit
End If


MDays =  int(objArgs(0))

On Error Resume Next
Set oWU = CreateObject("Microsoft.Update.Searcher")

If Err.Number <> 0 Then
WScript.StdOut.Write statusUnknown & "WU5 programming interface does not exist.", vbInformation + vbSystemModal, "Update history"
WScript.Quit
End If
On Error Goto 0

iTHCount = oWU.GetTotalHistoryCount
If iTHCount > 0 Then

   Set colUpdate = oWU.QueryHistory(0, iTHCount)
   For Each oUpdate In colUpdate

    if oUpdate.ResultCode = 2 then
    k = DateDiff("d",oUpdate.Date,DateValue(Now))
        if k<Cnt then
            Cnt = k
            Dat = oUpdate.Date
        End If
     End If
   Next

if Cnt = 9999999 then
  WScript.StdOut.Write statusUnknown & "Windows Updates not found"
else
   If Cnt>MDays then
      WScript.StdOut.Write statusBad & " Days:" & Cnt & " Last update:" & DateValue(Dat)
   else
      WScript.StdOut.Write statusOk & " Days:" & Cnt & " Last update:" & DateValue(Dat)
   End If
End if
End If
Regards
Alex
sysadmber
Posts: 50
Joined: Tue Dec 08, 2015 1:26 am

Post by sysadmber »

Thank you very much.

This did the trick.
Kris
Posts: 375
Joined: Wed May 12, 2010 3:22 am

Post by Kris »

Hi Guys,

I am trying to accomplish the same.
The only difference is that the machines are on several different domains, so I need an option to send credentials along with the test.

Any ideas?

Thanks!
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

For security and reliability we always recommend to install RMA agent when you need to check several LANs/domains
http://www.ks-soft.net/hostmon.eng/rma-win/index.htm

Regards
Alex
Post Reply