'==========================================================================
'
' NAME: Report180DayExpiration.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL : [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE : 2/15/2006
'
' COMMENT: <comment>
'
'==========================================================================
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
installDate = dConvertWMItoVBSDate(objItem.InstallDate)
Next
expireDate = installDate + 180
daysToExpiration = DateDiff("d",Now, expireDate)
Report = "Windows was installed on " & installDate & vbCrLf
Report = Report & "and expires on " & expireDate & "." & vbCrLf
Report = Report & "There are " & daysToExpiration & " days left until expiration."
MsgBox Report
Private Function dConvertWMItoVBSDate(sDate)
Dim sMonth, sDay, sYear, sHour, sMinutes, sSeconds
sMonth = Mid(sDate,5,2)
sDay = Mid(sDate,7,2)
sYear = Mid(sDate,1,4)
sHour = Mid(sDate,9,2)
sMinutes = Mid(sDate,11,2)
sSeconds = Mid(sDate,13,2)
dConvertWMItoVBSDate = DateSerial (sYear, sMonth, sDay) + TimeSerial (sHour, sMinutes, sSeconds)
End Function