Hey guys, I've recently had to put together some scripts for special purposes here at work. I thought I'd share a couple that someone might find useful. Bits and pieces of the scripts were lifted from examples from various places, so I don't claim to have come up with all the code. I claim to have put various things together to make it useful to me :) So here you go.
This first one was a simple server restart HTA script.
<html>
<head>
<title>iBOOT</title>
<HTA:APPLICATION
APPLICATIONNAME="iBOOT"
ID="MyHTMLapplication"
maximizeButton="no"
VERSION="1.01"/>
</head> <script language="VBScript"> Dim intOption
Dim strComputer
Dim intUp
Dim intDown
Dim strMessage
Dim dtmStartTime
Dim strMsg
Dim intYesNo
intUp = 0
intDown = 0 Sub Window_OnLoad
CenterWindow
SetRadioButtons
txtMessage.Value = Now & ": Application started." & vbCrLf
End Sub
Sub CenterWindow On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
intLeft = (intHorizontal - 575) / 2
intTop = (intVertical - 500) / 2
window.resizeTo 575,500
window.moveTo intLeft, intTop End Sub Function GetbtnOptionsRadioValue()
For i=0 to btnOptions.length-1
If btnOptions.Item(i).Checked Then
GetbtnOptionsRadioValue = btnOptions.Item(i).Value
Exit Function
End If
Next
GetbtnOptionsRadioValue = ""
End Function
Sub CloseApp()
Self.close End Sub
Sub SetRadioButtons()
For Each objButton in btnOptions
If objButton.Value = "Restart" Then
objButton.Checked = True
End If
Next End Sub
Sub SubmitTask()
On Error Resume Next If txtServer.Value = "" Then
MsgBox "You must enter a Server Name or IP Address.", 16, "Error"
txtMessage.Value = txtMessage.Value & Now & ": Textbox empty." & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight
Exit Sub
Else
strComputer = txtServer.Value
End If
Set WshShell = CreateObject("WScript.Shell")
PINGFlag = Not CBool(WshShell.run("ping -n 1 " & strComputer,0,True))
If PINGFlag = True Then Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
Err.Clear
MsgBox "Access denied.", 16, "Error"
txtMessage.Value = txtMessage.Value & Now & ": Access denied: " & strComputer & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight
Exit Sub
End If
Else
strMsg = "Server '" & strComputer & "' could not be found on the network."
MsgBox strMsg, 16, "Error"
txtMessage.Value = txtMessage.Value & Now & ": Server not found: " & strComputer & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight
Exit Sub End If
strMsg = "Are you sure you want to execute this task on '" & strComputer & "' ? Click 'NO' if you want to cancel this operation."
intYesNo = MsgBox(strMsg, 4, "Confirm Task") If intYesNo = 6 Then
ExecuteTask
Else
txtMessage.Value = txtMessage.Value & Now & ": Operation cancelled." & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight
Exit Sub
End If
End Sub
Sub ExecuteTask For Each objButton in btnOptions
If objButton.Checked = True And objButton.Value = "Restart" Then
intOption = 6
End If
If objButton.Checked = True And objButton.Value = "Shutdown" Then
intOption = 5
End If
If objButton.Checked = True And objButton.Value = "Power Off (not graceful)" Then
intOption = 12
End If Next
DisableApp
txtMessage.Value = txtMessage.Value & Now & ": Task started on '" & strComputer & "'." & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Win32Shutdown(intOption)
Next
ServerMonitor End Sub
Sub DisableApp() txtServer.Disabled = True
For Each objButton in btnOptions
objButton.Disabled = True
Next
btnSubmit.Disabled = True
End Sub
Sub ServerMonitor() intUp = 0
intDown = 0 If intOption = 6 Then
MonitorRestart
End If
If intOption = 5 Then
MonitorShutdown
End If
If intOption = 12 Then
MonitorShutdown
End If
EnableApp End Sub
Sub MonitorShutdown() Do Until intDown = 1
Set WshShell = CreateObject("WScript.Shell")
PINGFlag = Not CBool(WshShell.run("ping -n 3 " & strComputer,0,True))
If PINGFlag = True Then
txtMessage.Value = txtMessage.Value & Now & ": Server is up... " & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight
Else
txtMessage.Value = txtMessage.Value & Now & ": Server is down... " & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight
intDown = 1
End If
Loop
strMsg = "Server '" & strComputer & "' is now offline."
MsgBox strMsg, 64, "Task Complete"
txtMessage.Value = txtMessage.Value & Now & ": '" & strComputer & "' is now offline." & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight End Sub
Sub MonitorRestart() Do Until intUp = 1 And intDown = 1
Set WshShell = CreateObject("WScript.Shell")
PINGFlag = Not CBool(WshShell.run("ping -n 3 " & strComputer,0,True))
If PINGFlag = True Then
txtMessage.Value = txtMessage.Value & Now & ": Server is up... " & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight
If intDown = 1 Then
intUp = 1
Else
intUp = 0
End If
Else
txtMessage.Value = txtMessage.Value & Now & ": Server is down... " & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight
intDown = 1
End If
Loop strMsg = "Server '" & strComputer & "' is now online. Please note: It may take several minutes before an RDP connection is possible."
MsgBox strMsg, 64, "Task Complete"
txtMessage.Value = txtMessage.Value & Now & ": '" & strComputer & "' is now online." & vbCrLf
txtMessage.scrollTop = txtMessage.scrollHeight End Sub
Sub EnableApp() txtServer.Disabled = False
For Each objButton in btnOptions
objButton.Disabled = False
Next
btnSubmit.Disabled = False End Sub </script> <body bgcolor="#ECE9D8">
<basefont size="2" color="black" face="arial"> <center>
<table cellspacing=0 cellpadding=0 bgcolor="black">
<tr>
<td bgcolor="ECE9D8">iBOOT v1.01</td>
</tr>
</table>
</center><br>
<center>
<table cellspacing=0 cellpadding=4 bgcolor="black">
<tr>
<td bgcolor="ECE9D8"><font size=2>Server Name or IP Address: </font></td>
<td bgcolor="ECE9D8"><input type="text" name="txtServer" id="txtServer" size="30"></td>
</tr>
</table>
</center><br> <center>
<table cellspacing=0 cellpadding=4 bgcolor="black">
<tr>
<td bgcolor="ECE9D8"></td>
<td bgcolor="ECE9D8"></td>
</tr>
<tr>
<td bgcolor="ECE9D8"></td>
<td bgcolor="ECE9D8"><font size=2><input type="radio" name="btnOptions" value="Restart"> Restart</font><BR></td>
</tr>
<tr>
<td bgcolor="ECE9D8"></td>
<td bgcolor="ECE9D8"><font size=2><input type="radio" name="btnOptions" value="Shutdown"> Shutdown</font><BR></td>
</tr>
<tr>
<td bgcolor="ECE9D8"></td>
<td bgcolor="ECE9D8"><font size=2><input type="radio" name="btnOptions" value="Power Off (not graceful)"> Power Off (not graceful)</font><BR></td>
</tr>
</table>
</center><br> <center>
<table cellspacing=0 cellpadding=4 bgcolor="black">
<tr>
<td bgcolor="ECE9D8"><font size=2><input type="button" name="btnSubmit" id="btnSubmit" value="Submit Task" onclick="SubmitTask" style="width:120px;"> </font></td>
<td bgcolor="ECE9D8"><font size=2> <input type="button" name="btnClose" id="btnClose" value="Close" onclick="CloseApp" style="width:120px;"></font></td>
</tr>
</table>
</center>
<center>
<table cellspacing=0 cellpadding=4 bgcolor="black">
<tr>
<td bgcolor="ECE9D8"><font size=2>Status:</font></td>
</tr>
<tr>
<td bgcolor="ECE9D8"><textarea style="background-color:ECE9D8" name="txtMessage" id="txtMessage" rows="10" cols="30" style="width:500px" readonly></textarea></td>
</tr>
</table>
</center>
<!--{{InsertControlsHere}}-Do not remove this line--> </basefont>
</body>
</html> The second one is a script to query servers for specific data I find useful:
<html>
<head>
<title>ProbeIT</title>
<HTA:APPLICATION
APPLICATIONNAME="ProbeIT"
ID="MyHTMLapplication"
maximizeButton="no"
VERSION="1.01"/>
</head> <script language="VBScript"> '----------A few parts of this script are based on various scripts found on the Internet.
'----------Many thanks to those that contributed.
On Error Resume Next Dim strTag, strComputerName, intProcCores, PINGFlag, strFileName, strFileNamePrint, InitFSO, intRows '----------program load event
Sub Window_OnLoad CenterWindow
cboServers.Focus
btnPrint.Disabled = True
btnExport.Disabled = True
cboServers.Value = ""
DataArea.InnerHTML = "<font size=3 color=#3A5FCD>Utility loaded. Please choose a server to scan.</font>"
End Sub '----------query the server for data
Sub OnClickButtonbtnQuery() ClearContents
If txtCustomServer.Value = "" Then
ExecuteQuery(cboServers.Value)
Else
ExecuteQuery(txtCustomServer.Value)
End If DataArea.InnerHTML = "<font size=3 color=#3A5FCD>Probe complete.</font>" End Sub '----------center the main program window
Sub CenterWindow On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
intLeft = (intHorizontal - 575) / 2
intTop = (intVertical - 840) / 2
window.resizeTo 575,840
window.moveTo intLeft, intTop End Sub '----------clear all data fields
Sub ClearContents() txtIP.Value = ""
txtProcModel.Value = ""
txtFrequency.Value = ""
txtCores.Value = ""
txtRAM.Value = ""
txtModel.Value = ""
txtTag.Value = ""
txtOSName.Value = ""
txtOSVersion.Value = ""
txtSP.Value = ""
txtStartDate.Value = ""
txtEndDate.Value = ""
txtDays.Value = ""
txtVM.Value = ""
txtDrives.Value = "" End Sub '----------sub for getting data from servers
Sub ExecuteQuery(strCName)
On Error Resume Next strComputerName = strCName
DataArea.InnerHTML = "<font size=3 color=#3A5FCD>Probing server for data...</font>"
Set WshShell = CreateObject("WScript.Shell")
PINGFlag = Not CBool(WshShell.run("ping -n 1 " & strComputerName,0,True))
If PINGFlag = True Then Set objWMIService = GetObject("winmgmts:\\" & strComputerName & "\root\cimv2")
If Err.Number <> 0 Then
Err.Clear
txtIP.Value = "ACCESS DENIED"
Exit Sub
End If
btnExport.Disabled = False
btnPrint.Disabled = False
Set colItems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objItem in colItems
txtOSName.Value = objItem.Caption
txtOSVersion.Value = objItem.Version
txtSP.Value = objItem.CSDVersion
Next
Else
txtIP.Value = "NO PING"
Exit Sub End If
If Left(txtOSName.Value, 9) = "Microsoft" Then '----------get processor info
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
intProcCores = 0 For Each objItem in colItems txtFrequency.Value = objItem.CurrentClockSpeed
txtProcModel.Value = objItem.Name
intProcCores = intProcCores + 1
Next
txtCores.Value = intProcCores
'----------get IP address
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
txtIP.Value = IPConfig.IPAddress(i)
Next
End If
Next
'----------get model/tag info
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
Set colItems = objWMIService.ExecQuery("Select Name, IdentifyingNumber from Win32_ComputerSystemProduct",,48)
For Each objItem in colItems
txtModel.Value = objItem.Name
txtTag.Value = objItem.IdentifyingNumber
Next '----------get memory information
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") For Each objComputer in colComputer
txtRAM.Value = Round(objComputer.TotalPhysicalMemory / 1073741824, 2)
Next
If txtModel.Value = "VMware Virtual Platform" then
txtVM.Value = "YES"
Else
txtVM.Value = "NO"
End If End If
GetDellWarrantyInfo
GetDriveInfo End Sub '----------print server data
Sub OnClickButtonbtnPrint()
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFileNamePrint = "tmp_prt.txt"
Set objFile = objFSO.CreateTextFile(strFileNamePrint)
If txtCustomServer.Value = "" Then
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Information report for server " & cboServers.Value & "."
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objFile.Write "Server Name:" & vbTab & vbTab & cboServers.Value
Else
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Information report for server " & txtCustomServer.Value & "."
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objFile.Write "Server Name:" & vbTab & vbTab & txtCustomServer.Value
End If
objfile.Write vbCr
objfile.Write vbCr
objFile.Write "IP Address:" & vbTab & vbTab & txtIP.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Processor Model:" & vbTab & txtProcModel.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Frequency:" & vbTab & vbTab & txtFrequency.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Number of Cores:" & vbTab & txtCores.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Total Memory:" & vbTab & vbTab & txtRAM.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Server Model:" & vbTab & vbTab & txtModel.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Server Tag:" & vbTab & vbTab & txtTag.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "OS Name:" & vbTab & vbTab & txtOSName.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "OS Version:" & vbTab & vbTab & txtOSVersion.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Service Pack:" & vbTab & vbTab & txtSP.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Warranty Start:" & vbTab & vbTab & txtStartDate.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Warranty Expire:" & vbTab & txtEndDate.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Warranty Days Left:" & vbTab & txtDays.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Storage:"
objfile.Write vbCr
objfile.Write vbCr
objfile.Write txtDrives.Value
objFile.Close Set objFile = objFSO.GetFile(strFileNamePrint)
strPath = objFSO.GetParentFolderName(objFile) Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(strPath)
Set objFolderItem = objFolder.ParseName(strFileNamePrint)
objFolderItem.InvokeVerbEx("Print")
End Sub '----------exit program
Sub OnClickButtonbtnClose() Self.close
End Sub '----------export data to file
Sub OnClickButtonbtnExport() On Error Resume Next
Const ForAppending = 8 Set ObjFSO = CreateObject("UserAccounts.CommonDialog")
ObjFSO.Filter = "Text|*.txt"
ObjFSO.FilterIndex = 2
ObjFSO.InitialDir = ""
InitFSO = ObjFSO.ShowOpen
If InitFSO = False Then
Exit Sub
Else
strFileName = ObjFSO.FileName
End If
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(strFileName, 1)
For x = 1 To 3
strCharacters = strCharacters & objFile.Read(x)
Next
If strCharacters = "Server" Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strFileName, ForAppending, True)
If txtCustomServer.Value = "" Then
objTextFile.WriteLine(cboServers.Value & vbTab & txtIP.Value & vbTab & txtProcModel.Value & vbTab & txtFrequency.Value & vbTab & txtCores.Value & vbTab & txtRAM.Value & vbTab & txtModel.Value & vbTab & txtTag.Value & vbTab & txtOSName.Value & vbTab & txtOSVersion.Value & vbTab & txtSP.Value & vbTab & txtStartDate.Value & vbTab & txtEndDate.Value & vbTab & txtDays.Value & vbtab & txtDrives.Value)
Else
objTextFile.WriteLine(txtCustomServer.Value & vbTab & txtIP.Value & vbTab & txtProcModel.Value & vbTab & txtFrequency.Value & vbTab & txtCores.Value & vbTab & txtRAM.Value & vbTab & txtModel.Value & vbTab & txtTag.Value & vbTab & txtOSName.Value & vbTab & txtOSVersion.Value & vbTab & txtSP.Value & vbTab & txtStartDate.Value & vbTab & txtEndDate.Value & vbTab & txtDays.Value & vbtab & txtDrives.Value)
End If
Else
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strFileName, ForAppending, True)
objTextFile.WriteLine("Server Name" & vbTab & "IP Address" & vbTab & "Processor Model" & vbTab & "Proc Frequency(Mhz)" & vbTab & "Proc Cores" & vbTab & "Memory" & vbTab & "Server Model" & vbTab & "Server Tag" & vbTab & "OS Name" & vbTab & "OS Version" & vbTab & "Service Pack" & vbTab & "Warranty Start" & vbTab & "Warranty End" & vbTab & "Days Left")
If txtCustomServer.Value = "" Then
objTextFile.WriteLine(cboServers.Value & vbTab & txtIP.Value & vbTab & txtProcModel.Value & vbTab & txtFrequency.Value & vbTab & txtCores.Value & vbTab & txtRAM.Value & vbTab & txtModel.Value & vbTab & txtTag.Value & vbTab & txtOSName.Value & vbTab & txtOSVersion.Value & vbTab & txtSP.Value & vbTab & txtStartDate.Value & vbTab & txtEndDate.Value & vbTab & txtDays.Value & vbtab & txtDrives.Value)
Else
objTextFile.WriteLine(txtCustomServer.Value & vbTab & txtIP.Value & vbTab & txtProcModel.Value & vbTab & txtFrequency.Value & vbTab & txtCores.Value & vbTab & txtRAM.Value & vbTab & txtModel.Value & vbTab & txtTag.Value & vbTab & txtOSName.Value & vbTab & txtOSVersion.Value & vbTab & txtSP.Value & vbTab & txtStartDate.Value & vbTab & txtEndDate.Value & vbTab & txtDays.Value & vbtab & txtDrives.Value)
End If
End If
txtMsg = "Data written to file " & strFileName & "."
MsgBox txtMsg,, "Confirmation"
objTextFile.Close
End Sub '----------contact Dell website and get warranty data
Sub GetDellWarrantyInfo() strTag = Trim(txtTag.Value)
If Len(strTag) = 7 then
CallDellWebSite
Else
txtStartDate.Value = "n/a"
txtEndDate.Value = "n/a"
txtDays.Value = "n/a"
End If End Sub '----------sub for contacting Dell
Sub CallDellWebSite arrHeadings = Array("Service Tag:", "Days Left") Set objHTTP = CreateObject("Msxml2.XMLHTTP")
Dim strField(400)
strfield(0) = Now 'Get SerialNumber (Service Tag)
strURL = "http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=" & strTag & "&~tab=1"
objHTTP.open "GET", strURL, False
objHTTP.send
strPageText = objHTTP.responseText
For Each strHeading In arrHeadings
intSummaryPos = InStr(LCase(strPageText), LCase(strHeading))
If intSummaryPos > 0 Then
intSummaryTableStart = InStrRev(LCase(strPageText), "<table", intSummaryPos)
intSummaryTableEnd = InStr(intSummaryPos, LCase(strPageText), "</table>") + 8
strInfoTable = Mid(strPageText, intSummaryTableStart, intSummaryTableEnd - intSummaryTableStart)
strInfoTable = Replace(Replace(Replace(strInfoTable, VbCrLf, ""), vbCr, ""), vbLf, "")
arrCells = Split(strInfoTable, "</td>")
' arrCells = Split(LCase(strInfoTable), "</td>")
For intCell = LBound(arrCells) To UBound(arrCells)
arrCells(intCell) = Trim(arrCells(intCell))
intOpenTag = InStr(arrCells(intCell), "<")
While intOpenTag > 0
intCloseTag = InStr(intOpenTag, arrCells(intCell), ">") + 1
strNewCell = ""
If intOpenTag > 1 Then strNewCell = strNewCell & Trim(Left(arrCells(intCell), intOpenTag - 1))
If intCloseTag < Len(arrCells(intCell)) Then strNewCell = strNewCell & Trim(Mid(arrCells(intCell), intCloseTag))
arrCells(intCell) = Replace(Trim(strNewCell), " Change Service Tag","")
intOpenTag = InStr(arrCells(intCell), "<")
Wend
Next
If LCase(arrCells(0)) = LCase("Service Tag:") Then ElseIf LCase(arrCells(0)) = LCase("Description") Then intRows = (intCell \ 5) - 1
For i = 1 to 1
txtStartDate.Value = arrCells((i * 5) + 4)
txtEndDate.Value = arrCells((i * 5) + 5)
txtDays.Value = arrCells((i * 5) + 6)
Next
End If
End If
Next
End Sub '----------scan server for logical hard drives
Sub GetDriveInfo() Set objWMIService = GetObject("winmgmts:\\" & strComputerName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk WHERE DriveType=3")
DIM strDiskSize, strFreeSpace, strusedSpace, strDriveData, strDiskID For Each objItem in colItems
If IsNull(objItem.Size) then
objItem.Size = 0
End if
If IsNull(objItem.FreeSpace) then
objItem.FreeSpace = 0
End if
strDiskID = objItem.DeviceID
strDiskSize = Round(objItem.Size /1073741824,2) & "gb"
strFreeSpace = Round(objItem.FreeSpace /1073741824,2) & "gb"
strusedSpace = Round((objItem.Size-objItem.FreeSpace)/1073741824,2) & "gb"
If txtDrives.Value = "" Then
txtDrives.Value = txtDrives.Value & "Disk ID: " & vbTab & strDiskID & vbCrlf & "Disk Size: " & vbTab & strDiskSize & vbCrlf & "Used Space: " & vbTab & strusedSpace & vbCrlf & "Free Space: " & vbTab & strFreeSpace & vbCrLf
Else
txtDrives.Value = txtDrives.Value & vbCrlf & "Disk ID: " & vbTab & strDiskID & vbCrlf & "Disk Size: " & vbTab & strDiskSize & vbCrlf & "Used Space: " & vbTab & strUsedSpace & vbCrlf & "Free Space: " & vbTab & strFreeSpace & vbCrLf
End If
Next End Sub '----------when combo box changes, clear server text box
Sub OnChangeSelectcboServers() txtCustomServer.Value = "" End Sub '----------runs before program exits, deletes temp print file if exists
Sub Window_onBeforeUnLoad On Error Resume Next Set objFSO2 = CreateObject("Scripting.FileSystemObject")
objFSO2.DeleteFile(strFileNamePrint)
End Sub </script> <body bgcolor="#ECE9D8">
<basefont size="2" color="black" face="arial">
Select server
<table cellspacing=0 cellpadding=4 bgcolor="black">
<tr>
<td bgcolor="#ECE9D8"><select name="cboServers" id="cboServers" onchange="OnChangeSelectcboServers">
<option value="ACPOP01">SERVER1</option>
<option value="XP-ARCHHK">SERVER2</option>
<option value="XRAY1">SERVER3</option>
</select></td>
<td bgcolor="#ECE9D8"><font size=2><input type="button" name="btnQuery" id="btnQuery" value="Query Server" onclick="OnClickButtonbtnQuery" style="width:120px;"></font></td>
<td bgcolor="#ECE9D8"><font size=2><input type="button" name="btnPrint" id="btnPrint" value="Print" onclick="OnClickButtonbtnPrint" style="width:120px;"></font></td>
</tr>
</table>
If not in list, input name here... <table cellspacing=0 cellpadding=4 bgcolor="black">
<tr>
<td bgcolor="#ECE9D8"><input type="text" name="txtCustomServer" id="txtCustomServer" size=24></td>
<td bgcolor="#ECE9D8"><input type="button" name="btnExport" id="btnExport" value="Export Data" onclick="OnClickButtonbtnExport" style="width:120px;"></td>
<td bgcolor="#ECE9D8"><font size=2><input type="button" name="btnClose" id="btnClose" value="Close" onclick="OnClickButtonbtnClose" style="width:120px;"></font></td>
</tr>
</table><BR>
<center><span id = "DataArea"></span></center><br> <table cellspacing=0 cellpadding=1 bgcolor="black"> <tr>
<td bgcolor="#ECE9D8"><font size=2><b><u>Hardware Information</u></b></font></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>IP Address: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtIP" id="txtIP" size="15" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Processor Model: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtProcModel" id="txtProcModel" size="45" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Frequency(Mhz): </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtFrequency" id="txtFrequency" size="8" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Core Count: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtCores" id="txtCores" size="3" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Memory(GB): </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtRAM" id="txtRAM" size="3" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2 color=#3A5FCD>Virtual Machine?: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtVM" id="txtVM" size="3" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2><B><u>Manufacturer Info </u></B></font></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Server Model: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtModel" id="txtModel" size="25" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Service Tag: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtTag" id="txtTag" size="8" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2><B><u>OS Information </u></B></font></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>OS Name: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtOSName" id="txtOSName" size="55" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>OS Version: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtOSVersion" id="txtOSVersion" size="10" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Service Pack: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtSP" id="txtSP" size="15" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><B><font size=2><u>Warranty Information </u></font></B></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Start Date: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtStartDate" id="txtStartDate" size="10" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>End Date: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtEndDate" id="txtEndDate" size="10" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Days Remaining: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtDays" id="txtDays" size="10" readonly></td>
</tr>
</table><BR> <table cellspacing=0 cellpadding=3 bgcolor="black">
<tr>
<td bgcolor="#ECE9D8"><font size=2><b>Storage Data...</b></font></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><textarea name="txtDrives" id="txtDrives" rows="8" cols="40" style="width:500px" readonly></textarea></td>
</tr>
</table>
</basefont>
</body>
</html> This last script I used to change the primary and/or secondary gateways on a server. This one I actually commented well :)
<html>
<head>
<title>ProbeIT</title>
<HTA:APPLICATION
APPLICATIONNAME="ProbeIT"
ID="MyHTMLapplication"
maximizeButton="no"
VERSION="1.01"/>
</head> <script language="VBScript"> '----------A few parts of this script are based on various scripts found on the Internet.
'----------Many thanks to those that contributed.
On Error Resume Next Dim strTag, strComputerName, intProcCores, PINGFlag, strFileName, strFileNamePrint, InitFSO, intRows '----------program load event
Sub Window_OnLoad CenterWindow
cboServers.Focus
btnPrint.Disabled = True
btnExport.Disabled = True
cboServers.Value = ""
DataArea.InnerHTML = "<font size=3 color=#3A5FCD>Utility loaded. Please choose a server to scan.</font>"
End Sub '----------query the server for data
Sub OnClickButtonbtnQuery() ClearContents
If txtCustomServer.Value = "" Then
ExecuteQuery(cboServers.Value)
Else
ExecuteQuery(txtCustomServer.Value)
End If DataArea.InnerHTML = "<font size=3 color=#3A5FCD>Probe complete.</font>" End Sub '----------center the main program window
Sub CenterWindow On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
intLeft = (intHorizontal - 575) / 2
intTop = (intVertical - 840) / 2
window.resizeTo 575,840
window.moveTo intLeft, intTop End Sub '----------clear all data fields
Sub ClearContents() txtIP.Value = ""
txtProcModel.Value = ""
txtFrequency.Value = ""
txtCores.Value = ""
txtRAM.Value = ""
txtModel.Value = ""
txtTag.Value = ""
txtOSName.Value = ""
txtOSVersion.Value = ""
txtSP.Value = ""
txtStartDate.Value = ""
txtEndDate.Value = ""
txtDays.Value = ""
txtVM.Value = ""
txtDrives.Value = "" End Sub '----------sub for getting data from servers
Sub ExecuteQuery(strCName)
On Error Resume Next strComputerName = strCName
DataArea.InnerHTML = "<font size=3 color=#3A5FCD>Probing server for data...</font>"
Set WshShell = CreateObject("WScript.Shell")
PINGFlag = Not CBool(WshShell.run("ping -n 1 " & strComputerName,0,True))
If PINGFlag = True Then Set objWMIService = GetObject("winmgmts:\\" & strComputerName & "\root\cimv2")
If Err.Number <> 0 Then
Err.Clear
txtIP.Value = "ACCESS DENIED"
Exit Sub
End If
btnExport.Disabled = False
btnPrint.Disabled = False
Set colItems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objItem in colItems
txtOSName.Value = objItem.Caption
txtOSVersion.Value = objItem.Version
txtSP.Value = objItem.CSDVersion
Next
Else
txtIP.Value = "NO PING"
Exit Sub End If
If Left(txtOSName.Value, 9) = "Microsoft" Then '----------get processor info
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
intProcCores = 0 For Each objItem in colItems txtFrequency.Value = objItem.CurrentClockSpeed
txtProcModel.Value = objItem.Name
intProcCores = intProcCores + 1
Next
txtCores.Value = intProcCores
'----------get IP address
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
txtIP.Value = IPConfig.IPAddress(i)
Next
End If
Next
'----------get model/tag info
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
Set colItems = objWMIService.ExecQuery("Select Name, IdentifyingNumber from Win32_ComputerSystemProduct",,48)
For Each objItem in colItems
txtModel.Value = objItem.Name
txtTag.Value = objItem.IdentifyingNumber
Next '----------get memory information
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") For Each objComputer in colComputer
txtRAM.Value = Round(objComputer.TotalPhysicalMemory / 1073741824, 2)
Next
If txtModel.Value = "VMware Virtual Platform" then
txtVM.Value = "YES"
Else
txtVM.Value = "NO"
End If End If
GetDellWarrantyInfo
GetDriveInfo End Sub '----------print server data
Sub OnClickButtonbtnPrint()
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFileNamePrint = "tmp_prt.txt"
Set objFile = objFSO.CreateTextFile(strFileNamePrint)
If txtCustomServer.Value = "" Then
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Information report for server " & cboServers.Value & "."
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objFile.Write "Server Name:" & vbTab & vbTab & cboServers.Value
Else
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Information report for server " & txtCustomServer.Value & "."
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objFile.Write "Server Name:" & vbTab & vbTab & txtCustomServer.Value
End If
objfile.Write vbCr
objfile.Write vbCr
objFile.Write "IP Address:" & vbTab & vbTab & txtIP.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Processor Model:" & vbTab & txtProcModel.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Frequency:" & vbTab & vbTab & txtFrequency.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Number of Cores:" & vbTab & txtCores.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Total Memory:" & vbTab & vbTab & txtRAM.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Server Model:" & vbTab & vbTab & txtModel.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Server Tag:" & vbTab & vbTab & txtTag.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "OS Name:" & vbTab & vbTab & txtOSName.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "OS Version:" & vbTab & vbTab & txtOSVersion.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Service Pack:" & vbTab & vbTab & txtSP.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Warranty Start:" & vbTab & vbTab & txtStartDate.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Warranty Expire:" & vbTab & txtEndDate.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Warranty Days Left:" & vbTab & txtDays.Value
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objfile.Write vbCr
objfile.Write "Storage:"
objfile.Write vbCr
objfile.Write vbCr
objfile.Write txtDrives.Value
objFile.Close Set objFile = objFSO.GetFile(strFileNamePrint)
strPath = objFSO.GetParentFolderName(objFile) Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(strPath)
Set objFolderItem = objFolder.ParseName(strFileNamePrint)
objFolderItem.InvokeVerbEx("Print")
End Sub '----------exit program
Sub OnClickButtonbtnClose() Self.close
End Sub '----------export data to file
Sub OnClickButtonbtnExport() On Error Resume Next
Const ForAppending = 8 Set ObjFSO = CreateObject("UserAccounts.CommonDialog")
ObjFSO.Filter = "Text|*.txt"
ObjFSO.FilterIndex = 2
ObjFSO.InitialDir = ""
InitFSO = ObjFSO.ShowOpen
If InitFSO = False Then
Exit Sub
Else
strFileName = ObjFSO.FileName
End If
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(strFileName, 1)
For x = 1 To 3
strCharacters = strCharacters & objFile.Read(x)
Next
If strCharacters = "Server" Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strFileName, ForAppending, True)
If txtCustomServer.Value = "" Then
objTextFile.WriteLine(cboServers.Value & vbTab & txtIP.Value & vbTab & txtProcModel.Value & vbTab & txtFrequency.Value & vbTab & txtCores.Value & vbTab & txtRAM.Value & vbTab & txtModel.Value & vbTab & txtTag.Value & vbTab & txtOSName.Value & vbTab & txtOSVersion.Value & vbTab & txtSP.Value & vbTab & txtStartDate.Value & vbTab & txtEndDate.Value & vbTab & txtDays.Value & vbtab & txtDrives.Value)
Else
objTextFile.WriteLine(txtCustomServer.Value & vbTab & txtIP.Value & vbTab & txtProcModel.Value & vbTab & txtFrequency.Value & vbTab & txtCores.Value & vbTab & txtRAM.Value & vbTab & txtModel.Value & vbTab & txtTag.Value & vbTab & txtOSName.Value & vbTab & txtOSVersion.Value & vbTab & txtSP.Value & vbTab & txtStartDate.Value & vbTab & txtEndDate.Value & vbTab & txtDays.Value & vbtab & txtDrives.Value)
End If
Else
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strFileName, ForAppending, True)
objTextFile.WriteLine("Server Name" & vbTab & "IP Address" & vbTab & "Processor Model" & vbTab & "Proc Frequency(Mhz)" & vbTab & "Proc Cores" & vbTab & "Memory" & vbTab & "Server Model" & vbTab & "Server Tag" & vbTab & "OS Name" & vbTab & "OS Version" & vbTab & "Service Pack" & vbTab & "Warranty Start" & vbTab & "Warranty End" & vbTab & "Days Left")
If txtCustomServer.Value = "" Then
objTextFile.WriteLine(cboServers.Value & vbTab & txtIP.Value & vbTab & txtProcModel.Value & vbTab & txtFrequency.Value & vbTab & txtCores.Value & vbTab & txtRAM.Value & vbTab & txtModel.Value & vbTab & txtTag.Value & vbTab & txtOSName.Value & vbTab & txtOSVersion.Value & vbTab & txtSP.Value & vbTab & txtStartDate.Value & vbTab & txtEndDate.Value & vbTab & txtDays.Value & vbtab & txtDrives.Value)
Else
objTextFile.WriteLine(txtCustomServer.Value & vbTab & txtIP.Value & vbTab & txtProcModel.Value & vbTab & txtFrequency.Value & vbTab & txtCores.Value & vbTab & txtRAM.Value & vbTab & txtModel.Value & vbTab & txtTag.Value & vbTab & txtOSName.Value & vbTab & txtOSVersion.Value & vbTab & txtSP.Value & vbTab & txtStartDate.Value & vbTab & txtEndDate.Value & vbTab & txtDays.Value & vbtab & txtDrives.Value)
End If
End If
txtMsg = "Data written to file " & strFileName & "."
MsgBox txtMsg,, "Confirmation"
objTextFile.Close
End Sub '----------contact Dell website and get warranty data
Sub GetDellWarrantyInfo() strTag = Trim(txtTag.Value)
If Len(strTag) = 7 then
CallDellWebSite
Else
txtStartDate.Value = "n/a"
txtEndDate.Value = "n/a"
txtDays.Value = "n/a"
End If End Sub '----------sub for contacting Dell
Sub CallDellWebSite arrHeadings = Array("Service Tag:", "Days Left") Set objHTTP = CreateObject("Msxml2.XMLHTTP")
Dim strField(400)
strfield(0) = Now 'Get SerialNumber (Service Tag)
strURL = "http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=" & strTag & "&~tab=1"
objHTTP.open "GET", strURL, False
objHTTP.send
strPageText = objHTTP.responseText
For Each strHeading In arrHeadings
intSummaryPos = InStr(LCase(strPageText), LCase(strHeading))
If intSummaryPos > 0 Then
intSummaryTableStart = InStrRev(LCase(strPageText), "<table", intSummaryPos)
intSummaryTableEnd = InStr(intSummaryPos, LCase(strPageText), "</table>") + 8
strInfoTable = Mid(strPageText, intSummaryTableStart, intSummaryTableEnd - intSummaryTableStart)
strInfoTable = Replace(Replace(Replace(strInfoTable, VbCrLf, ""), vbCr, ""), vbLf, "")
arrCells = Split(strInfoTable, "</td>")
' arrCells = Split(LCase(strInfoTable), "</td>")
For intCell = LBound(arrCells) To UBound(arrCells)
arrCells(intCell) = Trim(arrCells(intCell))
intOpenTag = InStr(arrCells(intCell), "<")
While intOpenTag > 0
intCloseTag = InStr(intOpenTag, arrCells(intCell), ">") + 1
strNewCell = ""
If intOpenTag > 1 Then strNewCell = strNewCell & Trim(Left(arrCells(intCell), intOpenTag - 1))
If intCloseTag < Len(arrCells(intCell)) Then strNewCell = strNewCell & Trim(Mid(arrCells(intCell), intCloseTag))
arrCells(intCell) = Replace(Trim(strNewCell), " Change Service Tag","")
intOpenTag = InStr(arrCells(intCell), "<")
Wend
Next
If LCase(arrCells(0)) = LCase("Service Tag:") Then ElseIf LCase(arrCells(0)) = LCase("Description") Then intRows = (intCell \ 5) - 1
For i = 1 to 1
txtStartDate.Value = arrCells((i * 5) + 4)
txtEndDate.Value = arrCells((i * 5) + 5)
txtDays.Value = arrCells((i * 5) + 6)
Next
End If
End If
Next
End Sub '----------scan server for logical hard drives
Sub GetDriveInfo() Set objWMIService = GetObject("winmgmts:\\" & strComputerName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk WHERE DriveType=3")
DIM strDiskSize, strFreeSpace, strusedSpace, strDriveData, strDiskID For Each objItem in colItems
If IsNull(objItem.Size) then
objItem.Size = 0
End if
If IsNull(objItem.FreeSpace) then
objItem.FreeSpace = 0
End if
strDiskID = objItem.DeviceID
strDiskSize = Round(objItem.Size /1073741824,2) & "gb"
strFreeSpace = Round(objItem.FreeSpace /1073741824,2) & "gb"
strusedSpace = Round((objItem.Size-objItem.FreeSpace)/1073741824,2) & "gb"
If txtDrives.Value = "" Then
txtDrives.Value = txtDrives.Value & "Disk ID: " & vbTab & strDiskID & vbCrlf & "Disk Size: " & vbTab & strDiskSize & vbCrlf & "Used Space: " & vbTab & strusedSpace & vbCrlf & "Free Space: " & vbTab & strFreeSpace & vbCrLf
Else
txtDrives.Value = txtDrives.Value & vbCrlf & "Disk ID: " & vbTab & strDiskID & vbCrlf & "Disk Size: " & vbTab & strDiskSize & vbCrlf & "Used Space: " & vbTab & strUsedSpace & vbCrlf & "Free Space: " & vbTab & strFreeSpace & vbCrLf
End If
Next End Sub '----------when combo box changes, clear server text box
Sub OnChangeSelectcboServers() txtCustomServer.Value = "" End Sub '----------runs before program exits, deletes temp print file if exists
Sub Window_onBeforeUnLoad On Error Resume Next Set objFSO2 = CreateObject("Scripting.FileSystemObject")
objFSO2.DeleteFile(strFileNamePrint)
End Sub </script> <body bgcolor="#ECE9D8">
<basefont size="2" color="black" face="arial">
Select server
<table cellspacing=0 cellpadding=4 bgcolor="black">
<tr>
<td bgcolor="#ECE9D8"><select name="cboServers" id="cboServers" onchange="OnChangeSelectcboServers">
<option value="ACPOP01">SERVER1</option>
<option value="XP-ARCHHK">SERVER2</option>
<option value="XRAY1">SERVER3</option>
</select></td>
<td bgcolor="#ECE9D8"><font size=2><input type="button" name="btnQuery" id="btnQuery" value="Query Server" onclick="OnClickButtonbtnQuery" style="width:120px;"></font></td>
<td bgcolor="#ECE9D8"><font size=2><input type="button" name="btnPrint" id="btnPrint" value="Print" onclick="OnClickButtonbtnPrint" style="width:120px;"></font></td>
</tr>
</table>
If not in list, input name here... <table cellspacing=0 cellpadding=4 bgcolor="black">
<tr>
<td bgcolor="#ECE9D8"><input type="text" name="txtCustomServer" id="txtCustomServer" size=24></td>
<td bgcolor="#ECE9D8"><input type="button" name="btnExport" id="btnExport" value="Export Data" onclick="OnClickButtonbtnExport" style="width:120px;"></td>
<td bgcolor="#ECE9D8"><font size=2><input type="button" name="btnClose" id="btnClose" value="Close" onclick="OnClickButtonbtnClose" style="width:120px;"></font></td>
</tr>
</table><BR>
<center><span id = "DataArea"></span></center><br> <table cellspacing=0 cellpadding=1 bgcolor="black"> <tr>
<td bgcolor="#ECE9D8"><font size=2><b><u>Hardware Information</u></b></font></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>IP Address: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtIP" id="txtIP" size="15" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Processor Model: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtProcModel" id="txtProcModel" size="45" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Frequency(Mhz): </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtFrequency" id="txtFrequency" size="8" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Core Count: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtCores" id="txtCores" size="3" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Memory(GB): </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtRAM" id="txtRAM" size="3" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2 color=#3A5FCD>Virtual Machine?: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtVM" id="txtVM" size="3" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2><B><u>Manufacturer Info </u></B></font></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Server Model: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtModel" id="txtModel" size="25" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Service Tag: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtTag" id="txtTag" size="8" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2><B><u>OS Information </u></B></font></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>OS Name: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtOSName" id="txtOSName" size="55" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>OS Version: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtOSVersion" id="txtOSVersion" size="10" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Service Pack: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtSP" id="txtSP" size="15" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><B><font size=2><u>Warranty Information </u></font></B></td>
<td bgcolor="#ECE9D8"></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Start Date: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtStartDate" id="txtStartDate" size="10" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>End Date: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtEndDate" id="txtEndDate" size="10" readonly></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><font size=2>Days Remaining: </font></td>
<td bgcolor="#ECE9D8"><input type="text" name="txtDays" id="txtDays" size="10" readonly></td>
</tr>
</table><BR> <table cellspacing=0 cellpadding=3 bgcolor="black">
<tr>
<td bgcolor="#ECE9D8"><font size=2><b>Storage Data...</b></font></td>
</tr>
<tr>
<td bgcolor="#ECE9D8"><textarea name="txtDrives" id="txtDrives" rows="8" cols="40" style="width:500px" readonly></textarea></td>
</tr>
</table>
</basefont>
</body>
</html> Hope others find use for them. Thanks