Simon336697
asked on
Combining 2 htas to make one hta
Hi nice people.
Guys,
I have 2 hta scripts that I would like to combine into one hta.
I have attached in the code snippet both hta scripts, and have simply called them hta1 (architecture) and hta2 (service pack).
The objective is to:
Be able to select to return just the service pack, or just the architecture, or both service pack and architecture, and output the results in tables.
More explanation is attached in an image i have uploaded.
Any help would be greatly appreciated. Thanks everyone.
Guys,
I have 2 hta scripts that I would like to combine into one hta.
I have attached in the code snippet both hta scripts, and have simply called them hta1 (architecture) and hta2 (service pack).
The objective is to:
Be able to select to return just the service pack, or just the architecture, or both service pack and architecture, and output the results in tables.
More explanation is attached in an image i have uploaded.
Any help would be greatly appreciated. Thanks everyone.
'======================================================== hta1 (architecture):
<head>
<title>Enumerate System Information on Remote Computers</title>
<HTA:APPLICATION
APPLICATIONNAME="Enumerate System Information"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<style type="text/css">
html {
font-family:arial;
font-size:smaller;
}
table {
border-collapse:collapse;
border:solid 1px black;
font-family:arial;
font-size:0.8em;
}
tr, td, th {
border-collapse:collapse;
border-style:solid;
}
td { border-width: 1px; }
</style>
</head>
<script language="vbscript">
Sub Window_onLoad
intWidth = 600
intHeight = 480
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
End Sub
Sub GetInfo
run_button.disabled = True
ComputerListFile.disabled = True
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
If ComputerListFile.Value <> "" Then
If objFSO.FileExists(ComputerListFile.Value) = True Then
Set List = objFSO.OpenTextFile(ComputerListFile.Value, ForReading)
strHTML = "<table width='40%' border=1 bgcolor='white'>" &_
"<th style='background:c0c0c0'><b>System</b></th><th style='background:c0c0c0'><b>Processor Type</b>"
Results.InnerHTML = strHTML
strHTML2 = "<table width='40%' border=1>" &_
"<th colspan='2' style='background:c0c0c0'><b>Number of Servers with:</b>"
Totals.InnerHTML = strHTML2
iArch1 = 0
iArch2 = 0
iArch3 = 0
iArch4 = 0
iArch5 = 0
iArchU = 0
iUnreach = 0
Do Until List.AtEndOfStream
strComputer = List.ReadLine
If Ping(strComputer) Then
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessors = objWMIService.ExecQuery _
("Select * From Win32_Processor")
For Each objProcessor in colProcessors
strArch = "Arch Unknown"
If objProcessor.Architecture = 0 Then strArch = "x86"
If objProcessor.Architecture = 1 Then strArch = "MIPS"
If objProcessor.Architecture = 2 Then strArch = "Alpha"
If objProcessor.Architecture = 3 Then strArch = "PowerPC"
If objProcessor.Architecture = 9 Then strArch = "x64"
Next
strHTML = strHTML &"<tr><td width='40%' border=1>" & strComputer &_
"</td><td bgcolor='green'><font color='white'>" &strArch & "</font><br>"
If strArch = "x86" then
iArch1=iArch1+1
Elseif strArch = "MIPS" then
iArch2=iArch2+1
Elseif strArch = "Alpha" then
iArch3=iArch3+1
Elseif strArch = "PowerPC" then
iArch4=iArch4+1
Elseif strArch = "x64" then
iArch5=iArch5+1
Else
iArchU=iArchU+1
End If
Else
iUnreach = iUnreach + 1
strHTML = strHTML &"<tr><td width='40%'>"& strComputer & "</td><td bgcolor='red'><font color='white'>Unreachable</font></td></tr><br>"
End If
Loop
strHTML2 = strHTML2 &"<tr><td width='80%' border=1>x86"&_
"</td><td>" &iArch1 & "<br>"&_
"<tr><td width='80%' border=1>MIPS"&_
"</td><td>" &iArch2 & "<br>"&_
"<tr><td width='80%' border=1>Alpha"&_
"</td><td>" &iArch3 & "<br>"&_
"<tr><td width='80%' border=1>PowerPC"&_
"</td><td>" &iArch4 & "<br>"&_
"<tr><td width='80%' border=1>x64"&_
"</td><td>" &iArch5 & "<br>"&_
"<tr><td width='80%' border=1>Unknown"&_
"</td><td>" &iArchU & "<br>"&_
"<tr><td width='80%' border=1>Unreachable"&_
"</td><td>" &iUnreach & "<br>"&_
List.Close
Totals.InnerHTML = strHTML2 &"</table>"
Results.InnerHTML = strHTML &"</table>"
Else
MsgBox "File does not exist: " & ComputerListFile.Value
End If
Else
MsgBox "Please specify a file name."
End If
run_button.disabled = False
ComputerListFile.disabled = False
End Sub
Function Ping(strComputer)
Dim objShell, boolCode
Set objShell = CreateObject("WScript.Shell")
boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
If boolCode = 0 Then
Ping = True
Else
Ping = False
End If
End Function
</script>
<body>
<input type="button" value="Run Script" name="run_button" onClick="GetInfo">
<input type="file" name="ComputerListFile"> <br><br>
<span id = "Totals"></span><br><br>
<span id = "Results"></span>
</body>
</html>
' end of hta 1
'============================================================ hta2 (service pack):
<head>
<title>Enumerate Service Pack on Remote Computers</title>
<HTA:APPLICATION
APPLICATIONNAME="Enumerate Service Pack on Remote Computers"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<style type="text/css">
html {
font-family:arial;
font-size:smaller;
}
table {
border-collapse:collapse;
border:solid 1px black;
font-family:arial;
font-size:0.8em;
}
tr, td, th {
border-collapse:collapse;
border-style:solid;
}
td { border-width: 1px; }
</style>
</head>
<script language="vbscript">
Sub Window_onLoad
intWidth = 600
intHeight = 480
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
End Sub
Sub GetServicePack
run_button.disabled = True
ComputerListFile.disabled = True
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
If ComputerListFile.Value <> "" Then
If objFSO.FileExists(ComputerListFile.Value) = True Then
Set List = objFSO.OpenTextFile(ComputerListFile.Value, ForReading)
strHTML = "<table width='40%' border=1 bgcolor='white'>" &_
"<th style='background:c0c0c0'><b>System</b></th><th style='background:c0c0c0'><b>Service Pack</b>"
Results.InnerHTML = strHTML
strHTML2 = "<table width='40%' border=1>" &_
"<th colspan='2' style='background:c0c0c0'><b>Number of Servers with:</b>"
Totals.InnerHTML = strHTML2
iSpack1 = 0
iSpack2 = 0
iSpackU = 0
iUnreach = 0
Do Until List.AtEndOfStream
strComputer = List.ReadLine
If Ping(strComputer) Then
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSpack = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objSpack in colSpack
strSpack = objSpack.ServicePackMajorVersion
Next
strHTML = strHTML &"<tr><td width='40%' border=1>" & strComputer &_
"</td><td bgcolor='green'><font color='white'>" &strSpack & "</font><br>"
If strSpack = "1" then
iSpack1=iSpack1+1
Elseif strSpack = "2" then
iSpack2=iSpack2+1
Else
iSpackU=iSpackU+1
End If
Else
iUnreach = iUnreach + 1
strHTML = strHTML &"<tr><td width='40%'>"& strComputer & "</td><td bgcolor='red'><font color='white'>Unreachable</font></td></tr><br>"
End If
Loop
strHTML2 = strHTML2 &"<tr><td width='80%' border=1>Service Pack 1"&_
"</td><td>" &iSpack1 & "<br>"&_
"<tr><td width='80%' border=1>Service Pack 2"&_
"</td><td>" &iSpack2 & "<br>"&_
"<tr><td width='80%' border=1>Unknown"&_
"</td><td>" &iSpackU & "<br>"&_
"<tr><td width='80%' border=1>Unreachable"&_
"</td><td>" &iUnreach & "<br>"&_
List.Close
Totals.InnerHTML = strHTML2 &"</table>"
Results.InnerHTML = strHTML &"</table>"
Else
MsgBox "File does not exist: " & ComputerListFile.Value
End If
Else
MsgBox "Please specify a file name."
End If
run_button.disabled = False
ComputerListFile.disabled = False
End Sub
Function Ping(strComputer)
Dim objShell, boolCode
Set objShell = CreateObject("WScript.Shell")
boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
If boolCode = 0 Then
Ping = True
Else
Ping = False
End If
End Function
</script>
<body>
<input type="button" value="Get Service Pack" name="run_button" onClick="GetServicePack">
<input type="file" name="ComputerListFile"> <br><br>
<span id = "Totals"></span><br><br>
<span id = "Results"></span>
</body>
</html>
request.jpg
ASKER
TakedaT,
Youve done it yet again.
Im going to really understand what you have done, and hopefully learn a great deal from a guru in you :>)
Thanks so much mate.
Youve done it yet again.
Im going to really understand what you have done, and hopefully learn a great deal from a guru in you :>)
Thanks so much mate.
ASKER
Tak,
Just one thing if that is ok mate.
It doesnt look like your great script is summing the totals correctly for the architecture?
Eg. for whether the system is an x86, x64 etc.
Just one thing if that is ok mate.
It doesnt look like your great script is summing the totals correctly for the architecture?
Eg. for whether the system is an x86, x64 etc.
Could you show me a screen shot as an example? I dont have the environment to test properly.
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tak, I cant thank you enough. You fixed it :>)
That is awesome Tak.
Take care.
Simon
That is awesome Tak.
Take care.
Simon
ASKER
Brilliant Tak :>)
Open in new window