Listing 1: Excerpt from EventLogQuery.hta ' BEGIN CALLOUT A BEGIN COMMENT ' Because you might be acquiring information from the security ' event log, include the security component. ' END COMMENT Set WMIService = GetObject("winmgmts:{impersonationLevel=" & _ "impersonate,(Security)}!\\" & strSrv & "\root\cimv2") BEGIN COMMENT ' Because impersonationLevel=impersonate is the default in WMI 1.5 and ' higher, you can use the following abbreviated line of code if desired: ' Set WMIService = GetObject("winmgmts:{(Security)}!\\" & _ ' strSrv & "\root\cimv2") ' You can use encrypting packets to achieve a higher level of security: ' Set WMIService = GetObject("winmgmts:{impersonationLevel=" & _ ' "impersonate,authenticationLevel=PktPrivacy,(Security)}!\\" & _ ' strSrv & "\root\cimv2") ' END COMMENT ' END CALLOUT A ' BEGIN COMMENT ' If the computer is inaccessible, launch Excel and write the error. ' END COMMENT If Err <> 0 Then If do_once Then Set XL = CreateObject("Excel.Application") XL.workbooks.Add XL.Sheets.Add.name = "EventLogDetail" XL.Visible = TRUE Call headers do_once = FALSE evnts_exist = TRUE 'events or errors exist End If XL.Cells(row, col).Value = "Unable to communicate with " & Trim(strsrv) row = row + 1 Err.Clear Else ' BEGIN CALLOUT B ' BEGIN COMMENT ' Clear any carriage returns that the user might have entered ' when supplying event codes. ' END COMMENT EventCodeFreeFormList = EventCodesAndFreeForm.value EventCodeFreeFormList = Replace(EventCodeFreeFormList,vbcrlf,"") ' BEGIN COMMENT ' If the Free Form radio button is selected, a multipurpose box ' isn't used for event codes. ' END COMMENT If Not R1(6).Checked Then ' BEGIN COMMENT ' Create an array of user-supplied event codes. ' END COMMENT MoECodes=split(EventCodeFreeFormList,",") FirstTime = TRUE For e = 0 To Ubound(MoECodes) ' BEGIN COMMENT ' Throw out any user-supplied text that isn't numeric. ' END COMMENT If IsNumeric(Trim(MoECodes(e))) Then ' BEGIN COMMENT ' Create the EventCode segment of the query statement. If it's ' the first event code, start the string with "EventCode=". Otherwise, ' concatenate to existing statement with "or EventCode=". ' END COMMENT If FirstTime Then mcodes = "EventCode='" & Trim(MoECodes(e)) & "'" FirstTime = FALSE Else mcodes = mcodes & " or EventCode = '" & Trim(MoECodes(e)) & "'" End If End If Next End If ' END CALLOUT B