'Dan Rullo
'drullo@team1systems.com
'To Do: Resources, Driver dates & versions

On Error Resume Next
Dim ScriptName, ScriptRevDate, strComputer, colArgs, DefaultRunMode, RunMode, OutFile, Extension, FSO, FileHandle, WshShell, WshEnv, T1Serial, objReg, SystemName
ScriptName = "System Inventory Reporting Tool For Windows"
ScriptRevDate = "February 3, 2004"
DefaultRunMode = "HTML"
'Colors for HTML
CONST Gold = "d1b52b", Red = "800000", Black = "000000", DkGold = "84721C"
CONST HKLM = &H80000002

Set FSO = CreateObject("Scripting.FilesystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set WshEnv = WshShell.Environment("process")
Set colArgs = WScript.Arguments
InterpretArgs

strComputer = InputBox("Enter the name of the computer in your domain that you want to query." & Chr(13) & Chr(13) & _
	"Enter a dot to query this computer.","Computer name",".")

If Not strComputer = "" Then
	If RunMode = "TEXT" Or RunMode = "HTML" Then
		If RunMode = "TEXT" Then
			Extension = ".txt"
		ElseIf RunMode = "HTML" Then
			Extension = ".htm"
		End If
		OutFile = InputBox("Please enter a filename for the " & RunMode & " file that will contain the output generated by this script.","Specify Filename",WshEnv("USERPROFILE") & "\Desktop\SysInfo" & Extension)
		If OutFile = "" Then
			WScript.Quit
		Else
			Set FileHandle = FSO.CreateTextFile(OutFile, True)
			If RunMode = "HTML" Then HTMLHeader
		End If
	End If

	If Not RunMode = "HTML" Then
		Call Output(ScriptName,"Data","Yes", Black)
		Call Output("Written by Dan Rullo  /  Revised: " & ScriptRevDate,"Data","Yes", Black)
		Call Output("This output file generated: " & Now,"Data","Yes", Black)
		Call Output(Chr(13),"Data","Yes", Black)
	End If

	Dim wbemServices, wbemObjectSet, Value

	Set wbemServices = GetObject("winmgmts:\\" & strComputer)
	Set objReg = GetObject("winmgmts:{impersonationlevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

	'####### Get System Name
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_ComputerSystem")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		SystemName = .Name
	End With
	Next
	
	'####### Get Team 1 Serial Number
	objReg.GetStringValue HKLM, "SYSTEM\CurrentControlSet\Control\Session Manager\Environment","T1Serial",T1Serial
	Err.Clear
	If IsNull(T1Serial) Then
		'!!!!!!! Get Team 1 serial number
		'Valid Team 1 serial number entries are:
		'T1-999999-01	Length = 12
		'T199999901	Length = 10
		'99999901	Length = 8
		'999999-01	Length = 9
		'T1-99999901	Length = 11
		'T1999999-01	Length = 11

		T1Serial = Inputbox ("Please enter the Team 1 Systems serial number for " & SystemName & ".  You can find the serial number on the back of the system.  It should look similar to this:" & chr(13) & chr(13) & "T1-999999-99","Enter Team 1 Serial","T1-999999-99")

		T1Serial = Ucase(T1Serial)

		Select Case Len(T1Serial)
			Case 8:
				T1Serial = "T1-" & Left(T1Serial,6) & "-" & Right(T1Serial,2)
			Case 9:
				T1Serial = "T1-" & T1Serial
			Case 10:
				T1Serial = "T1-" & Mid(T1Serial,3,6) & "-" & Right(T1Serial,2)
			Case 11:
				If Mid(T1Serial,3,1) = "-" Then
					T1Serial = Left(T1Serial,9) & "-" & Right(T1Serial,2)
				else
					T1Serial = "T1-" & Right(T1Serial,9)
				end if
			Case 12:
				'Entered properly
			Case Else:
				'No serial number entered - big deal
		End Select

		If Not T1Serial = "" Then
			'!!!!!!! Put Team 1 serial number in registry (for environment variable)
			objReg.SetStringValue HKLM, "SYSTEM\CurrentControlSet\Control\Session Manager\Environment","T1Serial",T1Serial
		End If
	End If

	'####### Write System Name And Serial Number
	Call Output("System information for " & SystemName,"Bold","Yes", Gold)
	If Not IsNull(T1Serial) And Not T1Serial = "" Then Call Output("Team 1 Systems serial number: " & T1Serial,"Bold","Yes", Gold)

	'####### Memory Header
	If RunMode = "HTML" Then Call Output("<BR>","Data","No",Black)
	Call Output("##################### Memory Information #####################","Bold","Yes",Red)
	
	'####### Get Memory Count
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_LogicalMemoryConfiguration")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		Value = .TotalPhysicalMemory
		If Value > 1073741823 Then
			Value = Truncate(((Value / 1024) / 1024) / 1024) & " TB"
		ElseIf Value > 1048575 Then
			Value = Truncate((Value / 1024) / 1024) & " GB"
		ElseIf Value > 1023 Then
			Value = Truncate(Value / 1024) & " MB"
		Else
			Value = Truncate(Value) & " KB"
		End If
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("Total Physical Memory: " & Value,"Data","Yes", Black)
	End With
	Next

	'####### Get Memory Slot Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_MemoryDevice")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("Memory Device ID: " & .DeviceID,"Bold","Yes", Black)
		Call Output(vbTab & "Starting Address: " & .StartingAddress,"Data","Yes", Black)
		Call Output(vbTab & "Ending Address: " & .EndingAddress,"Data","Yes", Black)
		Value = .EndingAddress - .StartingAddress
		If Value > 1073741823 Then
			Value = Truncate(((Value / 1024) / 1024) / 1024) & " TB"
		ElseIf Value > 1048575 Then
			Value = Truncate((Value / 1024) / 1024) & " GB"
		ElseIf Value > 1023 Then
			Value = Truncate(Value / 1024) & " MB"
		Else
			Value = Truncate(Value) & " KB"
		End If
		Call Output("Size Of Memory Device: " & Value,"Data","Yes", Black)
	End With
	Next

	'####### Drive Header
	If RunMode = "HTML" Then Call Output("<BR>","Data","No",Black)
	If RunMode = "HTML" Then Call Output("<a name=" & Chr(34) & "Drive" & Chr(34) & "></a>","Data","No","None")
	Call Output("##################### Drive Information #####################","Bold","Yes",Red)
	If RunMode = "HTML" Then Call Output("<u><b><a href=" & Chr(34) & "#Top" & Chr(34) & "><Font Color=#" & DkGold & ">Return To Top</Font></a></b></u>","Bold","Yes",DkGold)
	
	'####### Get Hard Drive Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_DiskDrive")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("HDD ID: " & .DeviceID,"Bold","Yes", Black)
		Call Output(vbTab & "Type: " & .InterfaceType,"Data","Yes", Black)
		Call Output(vbTab & "Manufacturer: " & .Manufacturer,"Data","Yes", Black)
		Call Output(vbTab & "Model: " & .Model,"Data","Yes", Black)
		Value = .Size
		If Value > 1099511627776 Then
			Value = Truncate((((Value / 1024) / 1024) / 1024) / 1024) & " TB"
		ElseIf Value > 1073741823 Then
			Value = Truncate(((Value / 1024) / 1024) / 1024) & " GB"
		ElseIf Value > 1048575 Then
			Value = Truncate((Value / 1024) / 1024) & " MB"
		ElseIf Value > 1023 Then
			Value = Truncate(Value / 1024) & " KB"
		Else
			Value = Truncate(Value) & " B"
		End If
		Call Output(vbTab & "Size: " & Value,"Data","Yes", Black)
	End With
	Next

	'####### Get Partition Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_DiskPartition")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("Partition ID: " & .DeviceID,"Bold","Yes", Black)
		Call Output(vbTab & "Caption: " & .Caption,"Data","Yes", Black)
		Call Output(vbTab & "Disk Index: " & .DiskIndex,"Data","Yes", Black)
		If LCase(.Bootable) = "true" Then
			Call Output(vbTab & "Bootable: " & .Bootable,"Data","Yes", Black)
		Else
			Call Output(vbTab & "Bootable: " & "False","Data","Yes", Black)
		End If
		Call Output(vbTab & "Primary Partition: " & .PrimaryPartition,"Data","Yes", Black)
		Call Output(vbTab & "Description: " & .Description,"Data","Yes", Black)
		Call Output(vbTab & "Block Size: " & .BlockSize,"Data","Yes", Black)
		Call Output(vbTab & "Number Of Blocks: " & .NumberOfBlocks,"Data","Yes", Black)
		Value = .Size
		If Value > 1099511627776 Then
			Value = Truncate((((Value / 1024) / 1024) / 1024) / 1024) & " TB"
		ElseIf Value > 1073741823 Then
			Value = Truncate(((Value / 1024) / 1024) / 1024) & " GB"
		ElseIf Value > 1048575 Then
			Value = Truncate((Value / 1024) / 1024) & " MB"
		ElseIf Value > 1023 Then
			Value = Truncate(Value / 1024) & " KB"
		Else
			Value = Truncate(Value) & " B"
		End If
		Call Output(vbTab & "Size: " & Value,"Data","Yes", Black)
	End With
	Next

	'####### Get Logical Disk Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_LogicalDisk")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("Logical Disk ID: " & .DeviceID,"Bold","Yes", Black)
		Call Output(vbTab & "Description: " & .Description,"Data","Yes", Black)
		Call Output(vbTab & "Volume Name: " & .VolumeName,"Data","Yes", Black)
		Call Output(vbTab & "Volume Serial Number: " & .VolumeSerialNumber,"Data","Yes", Black)
		Call Output(vbTab & "Drive Type: " & .DriveType,"Data","Yes", Black)
		Call Output(vbTab & "Media Type: " & .MediaType,"Data","Yes", Black)
		Call Output(vbTab & "Filesystem: " & .FileSystem,"Data","Yes", Black)
		Value = .Size
		If Value > 1099511627776 Then
			Value = Truncate((((Value / 1024) / 1024) / 1024) / 1024) & " TB"
		ElseIf Value > 1073741823 Then
			Value = Truncate(((Value / 1024) / 1024) / 1024) & " GB"
		ElseIf Value > 1048575 Then
			Value = Truncate((Value / 1024) / 1024) & " MB"
		ElseIf Value > 1023 Then
			Value = Truncate(Value / 1024) & " KB"
		Else
			Value = Truncate(Value) & " B"
		End If
		If Value = " B" Then
			Call Output(vbTab & "Size: " & "[Null Value]","Data","Yes", Black)
		Else
			Call Output(vbTab & "Size: " & Value,"Data","Yes", Black)
		End If
		Value = .FreeSpace
		If Value > 1099511627776 Then
			Value = Truncate((((Value / 1024) / 1024) / 1024) / 1024) & " TB"
		ElseIf Value > 1073741823 Then
			Value = Truncate(((Value / 1024) / 1024) / 1024) & " GB"
		ElseIf Value > 1048575 Then
			Value = Truncate((Value / 1024) / 1024) & " MB"
		ElseIf Value > 1023 Then
			Value = Truncate(Value / 1024) & " KB"
		Else
			Value = Truncate(Value) & " B"
		End If
		If Value = " B" Then
			Call Output(vbTab & "Size: " & "[Null Value]","Data","Yes", Black)
		Else
			Call Output(vbTab & "Free Space: " & Value,"Data","Yes", Black)
		End If
	End With
	Next

	'####### Get CD-ROM Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_CDROMDrive")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No",Black)
		Call Output("CD-ROM Name: " & .Name,"Bold","Yes",Black)
		Call Output(vbTab & "ID: " & .DeviceID,"Data","Yes",Black)
		Call Output(vbTab & "Drive: " & .Drive,"Data","Yes",Black)
	End With
	Next
	
	'####### Platform Header
	If RunMode = "HTML" Then Call Output("<BR>","Data","No",Black)
	If RunMode = "HTML" Then Call Output("<a name=" & Chr(34) & "Platform" & Chr(34) & "></a>","Data","No","None")
	Call Output("##################### System Platform Information #####################","Bold","Yes",Red)
	If RunMode = "HTML" Then Call Output("<u><b><a href=" & Chr(34) & "#Top" & Chr(34) & "><Font Color=#" & DkGold & ">Return To Top</Font></a></b></u>","Bold","Yes",DkGold)
	
	'####### Get CPU Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_Processor")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("CPU ID: " & .DeviceID,"Bold","Yes", Black)
		Call Output(vbTab & "Manufacturer: " & .Manufacturer,"Data","Yes", Black)
		Call Output(vbTab & "Name: " & .Name,"Data","Yes", Black)
		Call Output(vbTab & "Description: " & .Description,"Data","Yes", Black)
		Call Output(vbTab & "ID Number: " & .ProcessorID,"Data","Yes", Black)
		Call Output(vbTab & "Revision: " & .Revision,"Data","Yes", Black)
		Call Output(vbTab & "Version: " & .Version,"Data","Yes", Black)
		Call Output(vbTab & "SocketType: " & .SocketDesignation,"Data","Yes", Black)
		Call Output(vbTab & "Address Width: " & .AddressWidth,"Data","Yes", Black)
		Call Output(vbTab & "Data Width: " & .DataWidth,"Data","Yes", Black)
		Call Output(vbTab & "Clock Speed: " & .CurrentClockSpeed,"Data","Yes", Black)
		Call Output(vbTab & "External Clock Speed: " & .ExtClock,"Data","Yes", Black)
		Call Output(vbTab & "Level 2 Cache: " & .L2CacheSize,"Data","Yes", Black)
	End With
	Next


	'####### Get BIOS Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_BIOS")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("BIOS Manufacturer: " & .Manufacturer,"Bold","Yes", Black)
		Call Output(vbTab & "Name: " & .Name,"Data","Yes", Black)
		Call Output(vbTab & "Version: " & .Version,"Data","Yes", Black)
		Call Output(vbTab & "SM Version: " & .SMBIOSBIOSVersion,"Data","Yes", Black)
		Call Output(vbTab & "Major/Minor Version: " & .SMBIOSMajorVersion & "." & .SMBIOSMinorVersion,"Data","Yes", Black)
		Call Output(vbTab & "Date: " & InterpretDate(.ReleaseDate),"Data","Yes", Black)
		Call Output(vbTab & "Serial Number: " & .SerialNumber,"Data","Yes", Black)
	End With
	Next

	'####### Get Operation System Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_OperatingSystem")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("Operating System Name: " & .Caption,"Bold","Yes", Black)
		Call Output(vbTab & "Version: " & .Version,"Data","Yes", Black)
		Call Output(vbTab & "Boot Device: " & .BootDevice,"Data","Yes", Black)
		Call Output(vbTab & "Serial Number: " & .SerialNumber,"Data","Yes", Black)
		Call Output(vbTab & "Build Number: " & .BuildNumber,"Data","Yes", Black)
		Call Output(vbTab & "Build Type: " & .BuildType,"Data","Yes", Black)
		Call Output(vbTab & "CSD Version: " & .CSDVersion,"Data","Yes", Black)
		Call Output(vbTab & "Service Pack Major/Minor Version: " & .ServicePackMajorVersion & "." & .ServicePackMinorVersion,"Data","Yes", Black)
		Call Output(vbTab & "Install Date: " & InterpretDate(.InstallDate),"Data","Yes", Black)
		Call Output(vbTab & "Last Boot: " & InterpretDate(.LastBootUpTime),"Data","Yes", Black)
		Call Output(vbTab & "Registered User: " & .RegisteredUser,"Data","Yes", Black)
		Call Output(vbTab & "Windows Directory: " & .WindowsDirectory,"Data","Yes", Black)
		Call Output(vbTab & "System Directory: " & .SystemDirectory,"Data","Yes", Black)
	End With
	Next

	'####### Additional Hardware Header
	If RunMode = "HTML" Then Call Output("<BR>","Data","No",Black)
	If RunMode = "HTML" Then Call Output("<a name=" & Chr(34) & "AdditionalHW" & Chr(34) & "></a>","Data","No","None")
	Call Output("##################### Additional Hardware Information #####################","Bold","Yes",Red)
	If RunMode = "HTML" Then Call Output("<u><b><a href=" & Chr(34) & "#Top" & Chr(34) & "><Font Color=#" & DkGold & ">Return To Top</Font></a></b></u>","Bold","Yes",DkGold)
	
	'####### Get Video Controller Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_VideoController")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("Video Controller ID: " & .DeviceID,"Bold","Yes", Black)
		Call Output(vbTab & "Description: " & .Description,"Data","Yes", Black)
		Call Output(vbTab & "Video Processor: " & .VideoProcessor,"Data","Yes", Black)
		Call Output(vbTab & "Architecture Type: " & .VideoArchitecture,"Data","Yes", Black)
		Call Output(vbTab & "Driver Date: " & InterpretDate(.DriverDate),"Data","Yes", Black)
		Call Output(vbTab & "Driver Version: " & .DriverVersion,"Data","Yes", Black)
		Call Output(vbTab & "Installed Display Drivers: " & .InstalledDisplayDrivers,"Data","Yes", Black)
		Call Output(vbTab & "Compatibility: " & .AdapterCompatibility,"Data","Yes", Black)
		Value = .AdapterRAM
		If Value > 1099511627776 Then
			Value = Truncate((((Value / 1024) / 1024) / 1024) / 1024) & " TB"
		ElseIf Value > 1073741823 Then
			Value = Truncate(((Value / 1024) / 1024) / 1024) & " GB"
		ElseIf Value > 1048575 Then
			Value = Truncate((Value / 1024) / 1024) & " MB"
		ElseIf Value > 1023 Then
			Value = Truncate(Value / 1024) & " KB"
		Else
			Value = Truncate(Value) & " B"
		End If
		Call Output(vbTab & "Adapter RAM: " & Value,"Data","Yes", Black)
		Call Output(vbTab & "Adapter RAM Type: " & .VideoMemoryType,"Data","Yes", Black)
		Call Output(vbTab & "Current Video Mode: " & .VideoModeDescription,"Data","Yes", Black)
		Call Output(vbTab & "Current Bits Per Pixel: " & .CurrentBitsPerPixel,"Data","Yes", Black)
		Call Output(vbTab & "Current Refresh Rate: " & .CurrentRefreshRate,"Data","Yes", Black)
		Call Output(vbTab & "Maximum Refresh Rate: " & .MaxRefreshRate,"Data","Yes", Black)
		Call Output(vbTab & "Minimum Refresh Rate: " & .MinRefreshRate,"Data","Yes", Black)
	End With
	Next

	'####### Get IDE Conroller Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_IDEController")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No",Black)
		Call Output("IDE Controller Name: " & .Name,"Bold","Yes",Black)
		Call Output(vbTab & "ID: " & .DeviceID,"Data","Yes",Black)
		Call Output(vbTab & "Manufacturer: " & .Manufacturer,"Data","Yes",Black)
	End With
	Next
	
	'####### Get SCSI Controller Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_SCSIController")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No",Black)
		Call Output("SCSI Controller Name: " & .Name,"Bold","Yes",Black)
		Call Output(vbTab & "ID: " & .DeviceID,"Data","Yes",Black)
		Call Output(vbTab & "Manufacturer: " & .Manufacturer,"Data","Yes",Black)
		Call Output(vbTab & "Driver: " & .DriverName,"Data","Yes",Black)
	End With
	Next
	
	'####### Get NIC Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_NetworkAdapter")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No", Black)
		Call Output("Network Adapter Device ID: " & .DeviceID,"Bold","Yes", Black)
		Call Output(vbTab & "Manufacturer: " & .Manufacturer,"Data","Yes", Black)
		Call Output(vbTab & "Description: " & .Description,"Data","Yes", Black)
		Call Output(vbTab & "Adapter Type: " & .AdapterType,"Data","Yes", Black)
		Call Output(vbTab & "MAC Address: " & .MacAddress,"Data","Yes", Black)
		Call Output(vbTab & "Service Name: " & .ServiceName,"Data","Yes", Black)
	End With
	Next

	'####### Driver Header
	If RunMode = "HTML" Then Call Output("<BR>","Data","No",Black)
	If RunMode = "HTML" Then Call Output("<a name=" & Chr(34) & "Driver" & Chr(34) & "></a>","Data","No","None")
	Call Output("##################### Driver Information #####################","Bold","Yes",Red)
	If RunMode = "HTML" Then Call Output("<u><b><a href=" & Chr(34) & "#Top" & Chr(34) & "><Font Color=#" & DkGold & ">Return To Top</Font></a></b></u>","Bold","Yes",DkGold)
	
	'####### Get Driver Information
	Set wbemObjectSet = wbemServices.InstancesOf("Win32_SystemDriver")
	For Each wbemObject In wbemObjectSet
	With wbemObject
		If RunMode = "HTML" Then Call Output("<BR>","Data","No",Black)
		Call Output("Driver Name: " & .Name,"Bold","Yes",Black)
		Call Output(vbTab & "Path: " & .PathName,"Data","Yes",Black)
		Call Output(vbTab & "Start Mode: " & .StartMode,"Data","Yes",Black)
		Call Output(vbTab & "State: " & .State,"Data","Yes",Black)
		Call Output(vbTab & "Service Type: " & .ServiceType,"Data","Yes",Black)
	End With
	Next
	
	Set wbemServices = Nothing
	Set wbemObjectSet = Nothing
	Set Value = Nothing
End If

If Not RunMode = "CONSOLE" Then
	If RunMode = "HTML" Then
		Call Output("</p>","Data","Yes", Black)
		Call Output("</CENTER>","Data","Yes", Black)
		Call Output("</BODY>","Data","Yes", Black)
		Call Output("</HTML>","Data","Yes", Black)
	End If
	FileHandle.Close
	WshShell.Run Chr(34) & OutFile & Chr(34), 3
End If

Set ScriptName = Nothing
Set ScriptRevDate = Nothing
Set strComputer = Nothing
Set colArgs = Nothing
Set DefaultRunMode = Nothing
Set RunMode = Nothing
Set OutFile = Nothing
Set Extension = Nothing
Set FSO = Nothing
Set FileHandle = Nothing
Set WshShell = Nothing
Set WshEnv = Nothing
Set T1Serial = Nothing
Set objReg = Nothing
Set SystemName = Nothing
WScript.Quit

Function Truncate(Val)
'This function will make sure that numbers are abreviated to no more than 2 decimal places
	If Not InStr(Val,".") = 0 Then
		If InStr(Val,".") + 2 < Len(Val) Then
			Truncate = Left(Val,InStr(Val,".") + 2)
		End If
	Else
		Truncate = Val
	End If
End Function

Sub InterpretArgs()
	Dim Arg, ArgCount
	If colArgs.Count > 0 Then
		ArgCount = ArgCount + 1
		For Each Arg In colArgs
			Select Case Ucase(Arg)
				Case "?","/?","-?","-H","-HELP","--HELP","--H","HELP":
					Help
				Case "TEXT", "/TEXT", "-TEXT", "--TEXT":
					RunMode = "TEXT"
					Exit For
				Case "HTML", "/HTML", "-HTML", "--HTML":
					RunMode = "HTML"
					Exit For
				Case "CONSOLE", "/CONSOLE", "-CONSOLE", "--CONSOLE":
					RunMode = "CONSOLE"
					Exit For
				Case Else:
					MsgBox "An invalid command line argument was specified!",vbCritical,"Runtime Error"
					Help
			End Select
		Next
	Else
		RunMode = DefaultRunMode
	End If
	If RunMode = "CONSOLE" And InStr(UCase(WScript.FullName),"WSCRIPT") > 0 Then
		If MsgBox("You are running this script from WSCRIPT - not CSCRIPT.  If you run in CONSOLE mode, all of the output from this script will be in the form of console message boxes (and that's a bunch of messages).  Are you sure you want to do this?",vbYesNo,"You Better Re-think This") = 7 Then
			WScript.Quit
		End If
	End If
	
	Set Arg = Nothing
	Set ArgCount = Nothing
End Sub

Sub Output(txtData, HTMLType, HTMLBreak, Color)
	Select Case UCase(RunMode)
		Case "TEXT":
			FileHandle.WriteLine(txtData)
		Case "HTML":
			If Not Color = "None" Then FileHandle.Write("<Font Color=#" & Color & ">")
			If HTMLType = "Bold" Then FileHandle.Write("<B>")
			If HTMLBreak = "Yes" Then
				FileHandle.WriteLine(txtData) & "<BR>"
			Else
				FileHandle.WriteLine(txtData)
			End If
			If HTMLType = "Bold" Then FileHandle.Write("</B>")
			If Not Color = "None" Then FileHandle.Write("</Font>")
		Case "CONSOLE":
			WScript.Echo txtData
	End Select
End Sub

Sub HTMLHeader()
	Call Output("<HTML>","Data","No", Black)
	Call Output("<HEAD><TITLE>Team 1 Systems</TITLE>","Data","No","None")
	Call Output("<script language=" & Chr(34) & "JavaScript1.2" & Chr(34) & ">","Data","No", "None")
	Call Output("<!--","Data","No", "None")
	Call Output("/***********************************************","Data","No", "None")
	Call Output("* Auto Maximize Window Script- © Dynamic Drive (www.dynamicdrive.com)","Data","No", "None")
	Call Output("* This notice must stay intact for use","Data","No", "None")
	Call Output("* Visit http://www.dynamicdrive.com/ for this script and 100's more.","Data","No", "None")
	Call Output("***********************************************/","Data","No", "None")
	Call Output("top.window.moveTo(0,0);","Data","No", "None")
	Call Output("if (document.all) {","Data","No", "None")
	Call Output("top.window.resizeTo(screen.availWidth,screen.availHeight);","Data","No", "None")
	Call Output("}","Data","No", "None")
	Call Output("else if (document.layers||document.getElementById) {","Data","No", "None")
	Call Output("if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){","Data","No", "None")
	Call Output("top.window.outerHeight = screen.availHeight;","Data","No", "None")
	Call Output("top.window.outerWidth = screen.availWidth;","Data","No", "None")
	Call Output("}","Data","No", "None")
	Call Output("}","Data","No", "None")
	Call Output("//-->","Data","No", "None")
	Call Output("</script>","Data","No", "None")
	Call Output("</HEAD>","Data","No", "None")
	Call Output("<BODY bgcolor=" & Chr(34) & "#FFFFee" & Chr(34) & " style=" & Chr(34) & "font-family: Georgia" & Chr(34) & " link=" & Chr(34) & "#800000" & Chr(34) & " vlink=" & Chr(34) & "#800000" & Chr(34) & " alink=" & Chr(34) & "#800000" & Chr(34) & ">","Data","No", "None")
	Call Output("<CENTER>","Data","No", "None")
	Call Output("<h3><font face=" & Chr(34) & "Georgia" & Chr(34) & " size=" & Chr(34) & "5" & Chr(34) & " color=" & Chr(34) & "#d1b52b" & Chr(34) & "><a name=" & Chr(34) & "Top" & Chr(34) & "></a>" & ScriptName & "</font></h3>","Data","No", Gold)
	Call Output("Written by Dan Rullo / Revised: " & ScriptRevDate,"Bold","Yes", Red)
	Call Output("This output file generated: " & Now,"Data","No", Black)
	Call Output("<HR>","Data","No", Black)
	Call Output("<b><u><a href=" & Chr(34) & "#Drive" & Chr(34) & "><font color=" & Chr(34) & "#" & DkGold & Chr(34) & ">Drive</font></a></u>&nbsp;&nbsp;&nbsp;<u><a href=" & Chr(34) & "#Platform" & Chr(34) & "><font color=" & Chr(34) & "#" & DkGold & Chr(34) & ">Platform</font></a></u>&nbsp;&nbsp;&nbsp; <u><a href=" & Chr(34) & "#AdditionalHW" & Chr(34) & "><font color=" & Chr(34) & "#" & DkGold & Chr(34) & ">Additional Hardware</font></a></u>&nbsp;&nbsp;&nbsp; <u><a href=" & Chr(34) & "#Driver" & Chr(34) & "><font color=" & Chr(34) & "#" & DkGold & Chr(34) & ">Drivers</font></a></u></b>","Data","No",DkGold)
	Call Output("<p>","Data","No", Black)
End Sub

Function InterpretDate(txtDate)
	'20020803053329.000000-240
	If InStr(txtDate,".") = 0 Then
		'I don't understand this date format
		InterpretDate = txtDate & " (Unknown Format)"
	Else
		Dim tmpStr
		tmpStr = Mid(txtDate,5,2) & "/" & Mid(txtDate,7,2) & "/"& Left(txtDate,4) & vbTab
		If IsNumeric(Mid(txtDate,9,1)) Then
			If Clng(Mid(txtDate,9,2)) < 12 Then
				tmpStr = tmpStr & Mid(txtDate,9,2) & ":" & Mid(txtDate,11,2) & ":" & Mid(txtDate,13,2)
			Else
				tmpStr = tmpStr & Clng(Mid(txtDate,9,2))-12 & ":" & Mid(txtDate,11,2) & ":" & Mid(txtDate,13,2)
			End If
			If Clng(Mid(txtDate,9,2)) < 12 Then
				tmpStr = tmpStr & " AM"
			Else
				tmpStr = tmpStr & " PM"
			End If
		End If
		InterpretDate = tmpStr
		Set tmpStr = Nothing
	End If
End Function

Sub Help()
	MsgBox ScriptName & " by Dan Rullo" & Chr(13) & _
		"Revised: " & ScriptRevDate & Chr(13) & Chr(13) & _
		"To run this script, type " & Chr(34) & "cscript " & WScript.ScriptName & Chr(34) & " from a command line." & Chr(13) & Chr(13) & _
		"This script provides command line arguments that you can use to specify where the generated output is directed.  Your choices are listed below:" & Chr(13) & Chr(13) & _
		"text:" & vbTab & "A text file is generated, then displayed." & Chr(13) & _
		"html:" & vbTab & "An HTML file is generated, then displayed." & Chr(13) & _
		"console:" & vbTab & "Output is displayed on the screen." & Chr(13) & _
		"help:" & vbTab & "Display this help message - no further action is taken." & Chr(13) & Chr(13) & _
		"If you specify TEXT or HTML, you will be prompted for a filename.  If you specify any combination of TEXT, HTML, and CONSOLE, the first argument found will be used.", vbInformation,"Help for " & WScript.ScriptName
	WScript.Quit
End Sub
