#128357 - 2004-10-25 04:15 AM
buildHTMLtree()
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
as doc is gone and no other commenters to old code found in:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB2&Number=127429&Main=127405#Post127429
built a new one, with minor change.
now it displays an image where tree can be expanded.
and, still now external stuff needed.
Code:
function buildHTMLtree($data)
dim $,$s,$bg,$section,$value
if 8<>vartype($data[0]) exit 1 endif
$buildHTMLtree='<span style="cursor:pointer;" id="s_' + $data[0] + '" onclick="var sauna = document.getElementById('
+"'"+$data[0]+"'"+"); var s2 = document.getElementById('s_"+$data[0]+"'); if (sauna.style.display == 'none')"
+" { sauna.style.display = 'block'; s2.innerHTML='<font face=Wingdings>1</font> <b>"+ $data[0]
+"</b>'; } else { sauna.style.display = 'none'; " +"s2.innerHTML='<font face=Wingdings>0</font> <b>"
+ $data[0] + "</b>';}" + '"><font face=Wingdings>0</font> <b>' + $data[0]
+ '</b></span><table id="' + $data[0] + '" style="display:none;"><tr><td width="20"> </td><td>'
for $section=1 to ubound($data)
if 0<ubound($data[$section])
if 8<>vartype($data[$section][1])
$buildHTMLtree=$buildHTMLtree+BuildHTMLtree($data[$section])
else
$buildHTMLtree=$buildHTMLtree+'<b>'+$data[$section][0]+'</b>'+
'<table><tr><td width="20"></td><td><table bgcolor="#EEEEEE">'
$bg=0
for $value=1 to ubound($data[$section])
$bg=$bg+1
$=split($data[$section][$value],chr(1))
$buildHTMLtree=$buildHTMLtree+'<tr '+iif($bg/2*2=$bg,'bgcolor="#FFFFFF"','')+'><td></td>'
for each $s in $ $buildHTMLtree=$buildHTMLtree+'<td>'+$s+'</td>' next
$buildHTMLtree=$buildHTMLtree+'</tr>'
next
$buildHTMLtree=$buildHTMLtree+'</table></td></tr></table>'
endif
endif
next
$buildHTMLtree=$buildHTMLtree+'</td></tr></table><br>'
endfunction
and here some example code to show how it works:
Code:
Function ListServices($Computer)
Dim $Service,$SL
For Each $Service In GetObject('winmgmts:{impersonationLevel=impersonate}!//' + $Computer + '\root\cimv2' ).ExecQuery('select * from Win32_Service', , 48)
$SL = $SL + chr(2) + $Service.Name + CHR(1) + $Service.DisplayName + CHR(1) + $Service.PathName + CHR(1) +
$Service.StartMode + CHR(1) + $Service.State + CHR(1) + $Service.StartName
Next
$ListServices=split($SL,chr(2))
EndFunction
Function ListProcess($Computer)
Dim $Process, $PL
For Each $Process In GetObject("winmgmts:{impersonationLevel=impersonate}!//" + $Computer ).ExecQuery("select * from Win32_Process")
If $Process.ExecutablePath = '' $Process.ExecutablePath = 'Path Unknown' EndIf
$PL = $PL + chr(2) + $Process.Name + CHR(1) + $Process.ProcessId + CHR(1) + $Process.ExecutablePath
Next
$ListProcess=split($PL,chr(1))
EndFunction
$HD="1","Model"+chr(1)+"IBM-DJSA-210","Interface"+chr(1)+"IDE","Size"+chr(1)+"10GB"
$HD2="2","Model"+chr(1)+"COM-CO10-JA0","Interface"+chr(1)+"SCSI","Size"+chr(1)+"9GB"
$OS="Operating System","Name"+chr(1)+"Windows 2000","Service Pack"+chr(1)+"4","Role"+chr(1)+"workstation","language"+chr(1)+"finnish"
$Antivir="Antivirus","Name"+chr(1)+"Fsecure AV","version"+chr(1)+"5.52","defTimeStamp"+chr(1)+"23.10.2004_03"
$services="Services",""
$services[1]=listServices(".")
$processes="Processes",""
$processes[1]=listServices(".")
$Hardware="Hardware",""
$Harddrives="Harddrives","",""
$Harddrives[1]=$hd
$Harddrives[2]=$hd2
$Hardware[1]=$harddrives
$software="Software","","","",""
$software[1]=$os
$software[2]=$antivir
$software[3]=$services
$software[4]=$processes
$header=@wksta,"",""
$header[1]=$hardware
$header[2]=$software
$ie = CreateObject("internetexplorer.application")
$ie.fullscreen = 1
$ie.menubar = 1
$ie.statusbar = 0
$ie.toolbar = 1
$ie.navigate("about:blank")
While $ie.busy AND $ie.readystate <> 4 AND @error = 0 Loop
$ie.document.write('<span style="position:absolute;right:10;cursor:pointer;" onclick="window.close()">Close</span>')
$ie.document.write(buildHTMLtree($header))
$ie.visible = 1
_________________________
!download KiXnet
|
Top
|
|
|
|
#128359 - 2004-10-26 10:10 PM
Re: buildHTMLtree()
|
Jose
Seasoned Scripter
Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
|
|
Top
|
|
|
|
#128360 - 2004-10-28 12:12 AM
Re: buildHTMLtree()
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
thanks for the comments... doc, I need you to run this against the system had a minor problem with diskdriveinfo(). change that function here and wanna know if the info is correct 100% now, k? btw, fixed a problem with the original code when the value part had only one array element of arrays not displaying properly.
Code:
$hd="DiskDrives",diskdriveinfo $OS="OS",split("Name"+chr(1)+"Windows 2000"+chr(2)+"Service Pack"+chr(1)+"4"+chr(2)+"Role"+chr(1)+"workstation"+chr(2)+"language"+chr(1)+"finnish",chr(2)) $Antivir="Antivirus",split("Name"+chr(1)+"Fsecure AV"+chr(2)+"version"+chr(1)+"5.52"+chr(2)+"defTimeStamp"+chr(1)+"23.10.2004_03",chr(2)) $proggies=proggielist(".") $Hardware="Hardware",$hd $software="Software",$os,$antivir,$proggies[0],$proggies[1] $header=@wksta,$hardware,$software ;$=open(1,@scriptdir+'\testoutput2.htm',5) ;writeline(1,buildHTMLtree($header)) ;$=close(1) ;run 'explorer "'+@scriptdir+'\testoutput2.htm"' $ie = CreateObject("internetexplorer.application") ; $ie.fullscreen = 1 $ie.menubar = 1 $ie.statusbar = 0 ; $ie.toolbar = 1 $ie.navigate("about:blank") While $ie.busy AND $ie.readystate <> 4 AND @error = 0 Loop $ie.document.write('<span style="position:absolute;right:10;cursor:pointer;" onclick="window.close()">Close</span>') $ie.document.write(buildHTMLtree($header,1)) ; $ie.document.body.background = @scriptdir+"\warn.jpg" $ie.visible = 1 function buildHTMLtree($data, optional $forceWrap) if 8<>vartype($data[0]) exit 1 endif $buildHTMLtree='<span style="cursor:pointer;" id="s_' + $data[0] + '" onclick="var sauna = document.getElementById(' +"'"+$data[0]+"'"+"); var s2 = document.getElementById('s_"+$data[0]+"'); if (sauna.style.display == 'none')" +" { sauna.style.display = 'block'; s2.innerHTML='<font face=Wingdings>1</font> <b>"+ $data[0] +"</b>'; } else { sauna.style.display = 'none'; " +"s2.innerHTML='<font face=Wingdings>0</font> <b>" + $data[0] + "</b>';}" + '"><font face=Wingdings>0</font> <b>' + $data[0] + '</b></span><table id="' + $data[0] + '" style="display:none;"><tr><td width="20"> </td><td>' $hc=0 for $section=1 to ubound($data) if 0<ubound($data[$section]) if 8<>vartype($data[$section][1]) $buildHTMLtree=$buildHTMLtree+BuildHTMLtree($data[$section]) $hc=1 endif endif if $hc=0 $buildHTMLtree=$buildHTMLtree+'<table><tr><td width="20"></td><td><table bgcolor="#EEEEEE">' $bg=0 for $value=0 to ubound($data[$section]) $bg=$bg+1 $=split($data[$section][$value],chr(1)) $buildHTMLtree=$buildHTMLtree+'<tr '+iif($bg/2*2=$bg,'bgcolor="#FFFFFF"','')+'><td></td>' for each $s in $ $buildHTMLtree=$buildHTMLtree+'<td>'+$s+'</td>' next $buildHTMLtree=$buildHTMLtree+'</tr>' next $buildHTMLtree=$buildHTMLtree+'</table></td></tr></table>' endif next $buildHTMLtree=$buildHTMLtree+'</td></tr></table><br>' endfunction Function proggieList($C) Dim $S,$L,$SL,$PL For Each $S In GetObject('winmgmts:{impersonationLevel=impersonate}!//'+$C+'\root\cimv2' ).ExecQuery('select * from Win32_Service', , 48) $SL = $SL+chr(2)+$S.Name+chr(1)+$S.DisplayName+chr(1)+$S.PathName+chr(1)+$S.StartMode+chr(1)+$S.State+chr(1)+$S.StartName Next For Each $P In GetObject('winmgmts:{impersonationLevel=impersonate}!//'+$C).ExecQuery('select * from Win32_Process') If $P.ExecutablePath = '' $P.ExecutablePath = 'Path Unknown' EndIf $PL = $PL+chr(2)+$P.Name+chr(1)+$P.ProcessId+chr(1)+$P.ExecutablePath Next $PL="Processes",split(substr($PL,2),chr(2)) $SL="Services",split(substr($SL,2),chr(2)) $proggielist=$SL,$PL EndFunction
Function DiskDriveInfo(optional $C) Dim $D,$DL,$Size,$ if not $C $C = "." endif For Each $D In GetObject('winmgmts:{impersonationLevel=impersonate}!//'+$C+'\root\cimv2' ).ExecQuery('select * from Win32_DiskDrive', , 48) $Size = (0.0+cint(""+((0.0+$D.Size) / 100000000)))/10 $DL = $DL + chr(2) + $D.Model + chr(1) + $D.interfacetype + chr(1) + $Size + 'GB' Next $DL = split(substr($DL,2),chr(2)) $DiskDriveInfo=$DL EndFunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#128362 - 2004-10-28 08:27 AM
Re: buildHTMLtree()
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
Hi Jooel,
Sorry for the late reply. I was out sick today.
Here is what I have on the drives
Quote:
Reported: VIA SATA RAID 0 SCSI Disk Device SCSI 320GB Actual: 320,078,512,128 bytes Reported: WDC WD2500JB-32FUA0 IDE 250GB Actual: 250,048,479,232 bytes AFT PRO - 9 CF USB Device USB 0GB AFT PRO - 9 MS USB Device USB 0GB AFT PRO - 9 SD USB Device USB 0GB AFT PRO - 9 SM/XD USB Device USB 0GB
And for comment on the Processes, it could use a little more spacing/buffer between columns. The PID almost seems to blend or be part of the path.
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 718 anonymous users online.
|
|
|