Hi Woolsdog,
Thank you for the response! The script I wrote is used to check for the hardware information of the server, such as manufacturer, serial number, model number, CPU type and speed, number of CPUs and total physical RAM. The code is listed below:
-----------------------------------------------------------
<html>
<head>
<title>System Hardware Information</title>
<HTA:APPLICATION
BORDER="thin"
BORDERSTYLE="normal"
CAPTION="yes"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
SCROLL="no"
SHOWINTASKBAR="no"
SYSMENU="yes"
WINDOWSTATE="normal" />
</head>
<style>
BODY
{
background-color: buttonface;
font-family: Helvetica;
font-size: 8pt;
margin-top: 15px;
margin-left: 8px;
margin-right: 8px;
margin-bottom: 3px;
}
textarea
{
font-family: Helvetica;
font-size: 10pt;
}
BUTTON
{
font-family: Arial;
font-size: 8pt;
width: 50px;
}
BUTTON.long
{
width: 75px;
{
</style>
<script language="VBScript">
Sub Window_Onload
self.Focus()
self.ResizeTo 330,400
self.moveTo 380,240
DomainOption(0).Checked = True
strDomain = "TEXAS"
strComputerName.focus
End Sub
'Refreshes the HTA page, which includes re-running any Windows_Onload code
Sub RunRefresh
Location.Reload(True)
End Sub
Sub SelectDomain
If DomainOption(1).Checked Then
strDomain = "STAGING"
End If
If DomainOption(2).Checked Then
strDomain = "TVNEXNET"
End If
End Sub
Sub RunScript
'set user credential to access the computer.
strUser = strDomain & "\" & strUserID.value
MyPassword = strPassword.value
Const MB_OK = 0
Const MB_ICONSTOP = 16
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set objShell = CreateObject("Wscript.Shell")
Set objNetwork = CreateObject("WScript.Network")
strLComputer = objNetwork.ComputerName
'Set proper computer location for the WMI query.
strComputer = strComputerName.value
Select Case UCase(strComputer)
Case ""
strComputer = strLComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Case strLComputer
strComputer = strLComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Case Else
If strUserID.value = Empty Then 'Display a message for user name input.
nMsgType = MB_OK Or MB_ICONSTOP
objShell.Popup "Please enter your user name!" & Space(5), 0, "User Name Requirement", nMsgType
Exit Sub
End If
If MyPassword = Empty Then 'Display a message for the password input.
nMsgType = MB_OK + MB_ICONSTOP
objShell.Popup "Please enter your password!" & Space(5), 0, "Password Requirement", nMsgType
Exit Sub
End If
On Error Resume Next
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer, "root/cimv2", strUser, MyPassword)
objWMIService.Security_.impersonationlevel = 3
If Err.number = 424 Then
nMsgType = MB_OK + MB_ICONSTOP
objShell.Popup "Error: Access Error." & Space(5) & vbCrLf _
& vbCrLf _
& "Please check your input information and try again." & Space(5), 0, "Access Error", nMsgType
Exit Sub
End If
On Error Goto 0
End Select
'Query for the hardware information.
Set colItems = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objItem In colItems
Msg.value = Msg.value & "Manufacturer: " & objItem.Manufacturer & vbCrLf
Msg.value = Msg.value & "Serial Number: " & objItem.SerialNumber & vbCrLf
Next
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
Msg.value = Msg.value & "Model: " & objItem.Name & vbCrLf
' Msg.value = Msg.value & "Serial Number: " & objItem.IdentifyingNumber & vbCrLf
Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem in colItems
CPUSpeed = objItem.CurrentClockSpeed
CPUType = Trim(objItem.Name)
Next
CPUType = Replace(CPUType, "(R)", "")
If InStr(CPUType, "Xeon(TM)") > 0 Then
CPUType = Replace(CPUType, "(TM)", "")
strCPUSpeed = Trim(Right(CPUType, 7))
CPUnSpeed = Split(CPUType, " ")(0) & " " & Split(CPUType, " ")(1) & " " & strCPUSpeed
ElseIf InStr(CPUType, "Pentium") > 0 Then
strCPUSpeed = Trim(Right(CPUType, 7))
If CPUSpeed < 1000 Then strCPUSpeed = CPUSpeed & "MHz"
CPUnSpeed = Split(CPUType, " ")(0) & " " & Split(CPUType, " ")(1) & " " & Split(CPUType, " ")(2) & " " & strCPUSpeed
End if
'Get physical RAM
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem in colItems
PhysRAM = objItem.TotalPhysicalMemory
CPUCount = objItem.NumberOfProcessors
Next
PhysRAM = FormatNumber(PhysRAM/1046856,0,GroupDigits)
Msg.Value = Msg.Value & "CPU/Speed: " & CPUnSpeed & vbCrLf
Msg.Value = Msg.Value & "Number of CPUs: " & CPUCount & vbCrLf
Msg.Value = Msg.Value & "Physical RAM (MB): " & PhysRAM & vbCrLf
End Sub
</script>
<body>
<b><font size="2" face="Arial">Computer Name:</b></b> <input type="text" name="strComputerName" size="18" font size="2" face="Arial"><BR>
</font><b><font size="2" face="Arial">User Name:</b> <input type="text" name="strUserID" size="12" font size="2" face="Arial"><BR>
</font><b><font size="2" face="Arial">Password: </b><input type="password" name="strPassword" size="12"><font size="2"></font>
<p align="left"></font> <b><font size="2" face="Arial">Please select a domain below:</b><BR>
</font> <input type="radio" name="DomainOption" value="1">TEXAS <input type="radio" name="DomainOption" value="2">STAGING <input type="radio" name="DomainOption" value="3">TVNEXNET<BR></p>
<p align="center"><input id=runbutton class="button" type="button" value=" OK " name="run_button" onClick="RunScript"></b>  <input type="button" value="Refresh" name="B0" onclick=RunRefresh> <input type="button" value="Cancel" name="B1" onclick=self.close()>
<p align="center"><b><font size="2" face=Arial">Hardware Information</b><BR><textarea rows="7" name="Msg" READONLY cols="45" style="text-align: left"></textarea></p>
</body>
</html>
-----------------------------------------------------------
I want to refresh only the Computer Name field and the Hardware Information field, and I want to keep the User Name and Password fields intact.
Thanks you for your help.
CluM09