I've tweaked the HTML code generation script to read INI files... all looping so any ini file with any number of sections can be read and displayed

The first section reads a straight ini and displays each section in its own table in 2 column format

The second reads another ini but splits the DATA field into additional columns

Code:

Break on
If Not IsDeclared($_UDF_LIB) Call @scriptdir+'\UDFs.kix' EndIf
If Not IsDeclared($_INV_LIB) Call @scriptdir+'\Inventory.kix' EndIf

$SerNo =WMIQuery("SerialNumber","Win32_BIOS")
If Len($SerNo) < 2
$SerNo=WMIQuery("SerialNumber","Win32_SystemEnclosure")
If InStr($serno,"|")
For Each $Return in Split($serno,"|")
If Len($Return)<10 $serno=$Return EndIf
Next
EndIf
EndIf
$SerNo =Trim(Ucase($SerNo))
$icon = @scriptdir + '\AHCA.ico'
$InvFile= @scriptdir + '\'+$SerNo+'.ini'
$SoftFile= @scriptdir + '\'+$SerNo+'_Software.ini'
$HTMLLog= @scriptdir + '\'+$SerNo+'.htm'

$haRd = '#cf2e4d'
$haBu = '#0000cf'
$hRed = '#ff0000'
$hBlu = '#0000ff'
$hGrn = '#00bb00'
$hBwn = '#800000'
$hBlc = '#000000'
$hgry = '#777777'
$bkgr = '#ffffcc'

if not exist($InvFile)
CollectData($InvFile)
ENDIF

$HTMLTableOpen = '<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse"'
+' bordercolor="#cccccc" width="100%" id="AutoNumber1">'+@CRLF
$HTMLTableClose= '</table>'+@CRLF
$ImageLocation = ''


; ********************************* Header *************************************

$WL = '<html>'+@CRLF
+'<head>'+@CRLF
+'<meta http-equiv="Content-Language" content="en-us">'+@CRLF
+'<meta name="GENERATOR" content=KiXtart '+@KIX+'>'+@CRLF
+'<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">'+@CRLF

+'<title>'+ 'Details on ' + $SerNo +'</title>'+@CRLF

+'</head>'+@CRLF
+'<body bgproperties="fixed" bgcolor="'+$bkgr+'" background="'+$ImageLocation+'">'+@CRLF
+'<p>'+@CRLF
+'<img src="Picture1.gif">'
+'<p><b><font size="5" color="'+$haBu+'">INVENTORY INFORMATION FOR: '+'</font></b>'+@CRLF
+'<b><font size="5" color="'+$haRd+'">'+$SerNo+'</font></b></p>'+@CRLF

; ****************************** Hardware Inventory *************************************

$sections = split(readprofilestring($InvFile,'',''),chr(10))
for each $section in $sections
if $section > " "
$wl = $wl +'<p><b><font size="4" color="'+$hBwn+'">'+$section+'</font></b></p>'+@CRLF
$wl = $wl + $HTMLTableOpen
$color= $hBlc,$hRed,$hBlc,$hBlc,$hRed
$Inv = Getini($InvFile,$section)
for $entry = 0 to ubound($Inv) step 2
$one = split($Inv[$entry],',')
if $entry+1 <= ubound($Inv)
$Two = split($Inv[$entry+1],',')
else
$Two = ' ',' ',' '
endif
$line = $one[1],$one[2],' ',$two[1],$two[2]
$wl = $wl + HTMLRow($line, $color)
next
$WL = $WL + $HTMLTableClose
endif
next

; ***************************** Software Inventory **********************************

$wl = $wl + '<p><b><font size="4" color="'+$hBwn+'">APPLICATIONS INSTALLED</font></b></p>'+@CRLF

$wl = $wl + $HTMLTableOpen
$color= $hBlc,$hBlc,$hRed,$hBlu,$hgrn

$sections = split(readprofilestring($SoftFile,'',''),chr(10))
for each $section in $sections
if $section > " "
$line = join(split($section,'_'),' '),' ',' ',' ',' '
$wl = $wl + HTMLRow($line, $color)

$SoftInv = Getini($SoftFile,$section,chr(9))
for each $entry in $SoftInv
$one = split($entry,chr(9))
redim preserve $one[5]
$line = ' ',$one[1],$one[2],$one[3],$one[4]
$wl = $wl + HTMLRow($line, $color)
next
endif
next
$WL = $WL + $HTMLTableClose


; ****************************** footer ***********************************

$WL = $WL +'<p><b><font size="2" color="'+$hBlu+'">'+"Date of report: "+@Date+'</font></b></p>'+@CRLF
+ '</body>'+@CRLF
+ '</html>'+@CRLF

; *****************************************************************************

del $HTMLLog

$Handle = FreeFileHandle()
$OpenFile = Open($Handle, $HTMLLog,5)
$WL = WriteLine($Handle,$WL + @CRLF)
$CloseFile = Close($Handle)

run 'cmd /c start iexplore "'+$htmllog+'"'



there are only a few UDFs used
Code:


If Not IsDeclared($_UDF_LIB)
Global $_UDF_LIB
EndIf



Function WMIQuery($what,$from,optional $computer,optional $where, optional $x)
Dim $strQuery, $objEnumerator, $value
If NOT $computer $computer="@WKSTA" EndIf
$strQuery = "Select $what From $from"
If $where AND $x $strQuery = $strQuery + " Where $where = '$x'" EndIf
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer")
$objEnumerator = $SystemSet.ExecQuery($strQuery)
For Each $objInstance in $objEnumerator
If @Error = 0 AND $objInstance <> ""
$=Execute("$$value = $$objInstance.$what")
$WMIQuery="$value"+"|"+"$WMIQuery"
EndIf
Next
$WMIQuery=Left($WMIQuery,Len($WMIQuery)-1)
Exit @error
EndFunction

Function ReadFile($file)
Dim $lf, $f, $_, $t
$lf=Chr(10)
$f=FreeFileHandle
$_=Open($f,$file)
If @error Exit @error EndIf
Do $t=$t+$lf+ReadLine($f) Until @error
$_=Close($f)
$ReadFile=Split(SubStr($t,2),$lf)
EndFunction

Function WriteFile($file,$array)
Dim $, $f, $line
If NOT VarType($Array) & 8192 Exit(1) EndIf
$f=FreeFileHandle
$=Open($f,$file,5)
If @error Exit @error EndIf
For Each $line in $array
$=WriteLine($f,$line+@crlf)
If @error Exit @error EndIf
Next
$=Close($f)
EndFunction

Function GetINI($File,optional $Section, optional $d)
DIM $Rootdata, $sec, $i, $ii, $secdata, $Error
DIM $Tarray[0]
If not $d $d = "," EndIf
If not Exist($file) Exit(2) EndIf
$Rootdata = Split(ReadProfileString($file,$section,""),CHR(10))
If UBound($rootdata) = 0 Exit(13) EndIf
ReDIM preserve $rootdata[ubound($rootdata)-1]
If not $section
$i = 0
For Each $sec In $rootdata
$secData = GetINI($file,$sec,$d)
$error = @ERROR
ReDIM preserve $tarray[UBound($tarray)+UBound($secdata)+1]
For $ii = 0 To UBound($secdata)
$tarray[$i] = $secdata[$ii]
$i = $i + 1
Next
Next
If UBound($tarray) > 0 ReDIM preserve $tarray[$i-1] EndIf
Else
ReDIM preserve $tarray[ubound($rootdata)]
For $i = 0 To UBound($rootdata)
$tarray[$i]=$section+$d+$Rootdata[$i]+$d+ReadProfileString($file,$section,$Rootdata[$i])
Next
EndIf
$GetINI = $tarray
Exit($error)
EndFunction

function arrayenumkey($regsubkey)
dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
if not keyexist($regsubkey) exit 87 endif
$subkeycounter=0
do
$currentsubkey=enumkey($regsubkey,$subkeycounter)
if not @ERROR
redim preserve $subkeyarray[$subkeycounter]
$subkeyarray[$subkeycounter]=$currentsubkey
$subkeycounter=$subkeycounter+1
endif
until @ERROR
$arrayenumkey=$subkeyarray
exit 0
endfunction

Function HTMLRow($arrElements, $arrColor)
$cols=Ubound($arrelements)
if not Ubound($arrelements) =Ubound($arrColor)
exit 1
endif
$colWidth = 100/($cols+1)
$HTMLRow = ' <tr>'+@CRLF
for $item = 0 to $cols
$HTMLRow = $HTMLRow +' <td width="'+$colwidth+'%" height="19"><font size="2" color="'+$arrColor[$item]+'">'+$arrElements[$item]+'</td>'+@CRLF
next
$HTMLRow = $HTMLRow +' </tr>'+@CRLF
Endfunction

return
Code:





_________________________
How to ask questions the smart way <-----------> Before you ask