' ' Read a CSV file to HTML page. ' From 'Read a CSV file' to console. ' JB 2012 ' Updated: 11:16 2012-02-22 ' Const adOpenStatic = 3 Const adLockOptimistic = 3 Const adCmdText = &H0001 '-- Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 '-- Dim fso, f, ts '-- Dim strHTML, strHTML1 '-- Dim strFile '-- Dim strHeader '-- System report first. strFile = "_system.txt" '-- strHeader = "This is a system report on this PC." '-- Set fso = CreateObject("Scripting.FileSystemObject") '-- Set f = fso.GetFile(strFile) ' Set ts = f.OpenAsTextStream(ForReading, TristateFalse) '-- strHTML1 = Replace( ts.ReadAll, vbCR, "
" ) strHTML1 = Replace( strHTML1, " >> ", "" ) strHTML1 = Replace( strHTML1, " << ", "" ) ' ts.Close ' '-- Software report second. strFile = "_software.csv" '-- strPathtoTextFile = "." '-- strHeader = "This is a report on software installed on this PC." '-- strOrder = "Caption" '-- strHTML1 = strHTML1 & WriteHTML( strFile, strPathtoTextFile, strHeader, strOrder ) '-- '-- Services report third. strFile = "_services.csv" '-- strPathtoTextFile = "." '-- strHeader = "This is a report on services running now on this PC." '-- strOrder = "Process Name" '-- strHTML = strHTML1 & WriteHTML( strFile, strPathtoTextFile, strHeader, strOrder ) '-- '-- Show it off! ReadHTMLString strHTML '-- Wscript.quit 0 ' ErrEx: Msgbox "Program error! " & Err.Description, 64 ' Wscript.quit 1 Function WriteHTML(strFile, strPathtoTextFile, strHeader, strOrder) ' ' ' '-- Dim strHTML '-- Set objConnection = CreateObject("ADODB.Connection") '-- Set objRecordSet = CreateObject("ADODB.Recordset") ' objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & strPathtoTextFile & ";" & _ "Extended Properties=""text;HDR=YES;FMT=Delimited""" '-- This worked! Sorting alphabetically the caption ' objRecordset.Open "SELECT * FROM " & strFile & " ORDER BY [" & strOrder & "]" , _ objConnection, adOpenStatic, adLockOptimistic, adCmdText '-- strHTML = "
" '-- For n = 0 to objRecordset.Fields.Count - 1 '-- strHTML = strHTML & "" Next '-- Do Until objRecordset.EOF '-- strHTML = strHTML & "" '-- For n = 0 to objRecordset.Fields.Count - 1 '-- strHTML = strHTML & "" '-- Next '-- strHTML = strHTML & "" '-- Next record objRecordset.MoveNext ' Loop '-- strHTML = "
" & strHeader & "
" & strHTML & "
" & objRecordset.Fields.Item(n).Name & "
" & objRecordset.Fields.Item(n) & "
" '-- WriteHTML = strHTML '-- End Function Sub ReadHTMLString(strText) ' ' ' '-- Set objIE = CreateObject("InternetExplorer.Application") '-- objIE.Navigate("about:blank") '-- objIE.Toolbar = 01 '-- objIE.StatusBar = 0 '-- Set objDoc = objIE.Document.Body '-- objIE.Document.Title = "Report Page - System Check - JBCS Support 2012" '-- objDoc.InnerHTML = "" & strText & "" '-- objIE.Visible = True set WshShell = WScript.CreateObject("WScript.Shell") '-- WshShell.AppActivate objIE '-- End Sub Function CScript() ' '-- test for CScript. False if not. ' If Instr(lcase(WScript.FullName), "cscript.exe") then '-- CScript = True Else CScript = False End if ' End Function