Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table in HTA

Status
Not open for further replies.

SaltyDog1960

IS-IT--Management
Feb 24, 2012
1
US
I would like to create 3 tables in this HTA script with each PC information in each column. I never created a table before. Thank you.



<head>
<title>IT</title>
<HTA:APPLICATION
IBORDER = "none"
CAPTION = "Yes"
CONTEXTMENU = "No"
INNERBORDER = "No"
MAXIMIZEBUTTON = "No"
MINIMIZEBUTTON = "Yes"
NAVIGABLE = "No"
SCROLL = "Yes"
SELECTION = "No"
SHOWINTASKBAR = "Yes"
SINGLEINSTANCE = "Yes"
SYSMENU = "Yes"
WINDOWSTATE = "Normal"
BORDER = "dialog"

>
</head>


<script language="VBScript">
'resizes and centers HTA window
Sub Window_onLoad
w = 1130
h = 850
Return = ResizeWindow(w, h)
Return = CenterWindow(w, h)

document.body.bgColor="Gainsboro"

End Sub


Function ResizeWindow(w, h)
width = w
height = h
window.resizeTo width, height
End Function
Function CenterWindow(w, h)
x = (screen.width-w)/2
y = (screen.height-h)/2
window.moveTo x, y
End Function
</script>




<SCRIPT LANGUAGE="VBScript">
'Uptime
strComputer = "PCNAME1"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")


set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime")
set colOS = objWMIService.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
objWMIDateTime.Value = objOS.LastBootUpTime
strLastBoot=objWMIDateTime.GetVarDate
strUptime=TimeSpan(objWMIDateTime.GetVarDate,Now)
Next

Set objDocument = self.Document
objDocument.Open
objDocument.Writeln "<body bgcolor='black'>"
objDocument.Writeln "<tr>"


objDocument.writeln "<Font Color='Black' face='Arial' size='2'></font>" & "Server Name:" & vbTab & strComputer & "</Font></td></br>"
If DateDiff ("h", strLastBoot, Now) > 48 Then
objDocument.writeln "<Font Color='Red' face='Arial' size='2'>" & "Last Boot: " & vbTab & strLastBoot & "</Font></td></br>"
Else
objDocument.writeln "<Font Color='blue' face='Arial' size='2'>" & "Last Boot: " & vbTab & strLastBoot & "</Font></td></br>"
End If
objDocument.writeln "<Font Color='Black' face='Arial' size='2'>" & "Uptime:" & vbTab & strUptime & "</Font></td></br></br>"




strComputer1 = "PCNAME2"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer1 & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")


set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime")
set colOS = objWMIService.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
objWMIDateTime.Value = objOS.LastBootUpTime
strLastBoot=objWMIDateTime.GetVarDate
strUptime=TimeSpan(objWMIDateTime.GetVarDate,Now) '& " (dd:hh:mm:ss)"
Next

Set objDocument1 = self.Document
objDocument1.Open
objDocument1.Writeln "<body bgcolor='black'>"
objDocument1.Writeln "<tr>"


objDocument1.writeln "<Font Color='Black' face='Arial' size='2'>" & "Server Name:" & vbTab & strComputer1 & "</Font></td></br>"
If DateDiff ("h", strLastBoot, Now) > 48 Then
objDocument1.writeln "<Font Color='Red' face='Arial' size='2'>" & "Last Boot: " & vbTab & strLastBoot & "</Font></td></br>"
Else
objDocument1.writeln "<Font Color='blue' face='Arial' size='2'>" & "Last Boot: " & vbTab & strLastBoot & "</Font></td></br>"
End If
objDocument1.writeln "<Font Color='Black' face='Arial' size='2'>" & "Uptime:" & vbTab & strUptime & "</Font></td></br></br>"




strComputer2 = "PCNAME3"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer2 & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")


set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime")
set colOS = objWMIService.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
objWMIDateTime.Value = objOS.LastBootUpTime
strLastBoot=objWMIDateTime.GetVarDate
strUptime=TimeSpan(objWMIDateTime.GetVarDate,Now) '& " (dd:hh:mm:ss)"
Next

Set objDocument2 = self.Document
objDocument2.Open
objDocument2.Writeln "<body bgcolor='black'>"
objDocument2.Writeln "<tr>"


objDocument2.writeln "<Font Color='Black' face='Arial' size='2'>" & "Server Name:" & vbTab & strComputer2 & "</Font></td></br>"
If DateDiff ("h", strLastBoot, Now) > 48 Then
objDocument2.writeln "<Font Color='Red' face='Arial' size='2'>" & "Last Boot: " & vbTab & strLastBoot & "</Font></td></br>"
Else
objDocument2.writeln "<Font Color='blue' face='Arial' size='2'>" & "Last Boot: " & vbTab & strLastBoot & "</Font></td></br>"
End If
objDocument2.writeln "<Font Color='Black' face='Arial' size='2'>" & "Uptime:" & vbTab & strUptime & "</Font></td></br></br>"



Function TimeSpan(dt1, dt2)
If (isDate(dt1) And IsDate(dt2)) = false Then
TimeSpan = "00:00:00:00:00"
Exit Function
End If

seconds = Abs(DateDiff("S", dt1, dt2))
minutes = seconds \ 60
hours = minutes \ 60
days = hours \ 24
hours = hours mod 24
minutes = minutes mod 60
seconds = seconds mod 60

if len(hours) = 1 then hours = "0" & hours

TimeSpan = days & ":" & _
RIGHT("00" & hours, 2) & ":" & _
RIGHT("00" & minutes, 2) & ":" & _
RIGHT("00" & seconds, 2)
End Function

</script>

<body>

</body>
</html>
 
Tables in HTA files are no different than they are in HTML code.

Code:
<table>
       <tr>
           <td>Box1</td><td>Box2</td>
       </tr>
       <tr>
           <td>Box3</td><td>Box4</td>
       </tr>
</table>

I recommend you try downloading the HTA Helpomatic from Microsoft to help you get started.



I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top