Jump to content

can i have a little help with a vbs script please?


Recommended Posts

Not meaning to stray so far off topic in your thread.. programs like CPU-Z, etc. are going through the management logic that reports temperatures, voltages, etc. WMI is capable of reporting quite a bit of info, but with nobody coming up with, much less following any sort of standard for those diagnostic data types, the developers have to resort to speaking directly to the hardware.

Link to comment
Share on other sites


Here is the new script I have add disk and partition information

'''' ***** - SCRIPT BY EYEBALL, GUNSMOKINGMAN, ROQUESPEAR - ***** ''''
'''' ***** - http://gunsmokingman.ath.cx/ - ***** ''''
Option Explicit
Dim strComputer : strComputer = "."
'''' *********************************************************************************
'''' VARIBLES FOR THE SCRIPT
Dim colComputer, objComputer, ComputerReport, Comp, CompReport, NumOfProc '''' --> colComputer
Dim Bios, objBios, BiosDate, BiosReportDate '''' --> Bios
Dim objProc, Processor, Proc, ProcMaker, ProcReport, Speed '''' --> Processor
Dim HardDrive, HDId, HDIid1, HdName, HDReport, HDSize, HDS, ObjHD '''' --> ObjHD
Dim ObjPart, PFreeSpace, Pfs, PSize, Ps, PReport, Partition, UsedSpace, Us '''' --> ObjPart
Dim IDate, InstallDate, objOs, OsInfo, OsName, N1, Ver '''' --> OsInfo
Dim InstalledSotware, objSoftware, Software, SWName, SWVer '''' --> Software
Dim BDate, BDate1, BDate2, BDate2a, BDate3 '''' Conver Wmi Date Format
Dim GB, MB : GB = 1024 * 1024 * 1024 : MB = 1024 * 1024 '''' --> Varibles To Convert Size
Dim Ts , S_3, S_5 '''' --> Text Output
S_3 = Space(3) : S_5 = Space(5) '''' --> Space Varibles
Dim Ln1 : Ln1 = S_3 & Chr(171) & " ------------ " & Chr(187) '''' --> Separator
'''' *********************************************************************************
'''' VARIBLES AND OBJECTS FOR SCRIPT
Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim DTop : DTop = Act.SpecialFolders("Desktop")
Dim FileReport : FileReport = DTop & "\ComputerReport.txt"
'''' *********************************************************************************
Dim objWMIService : Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'''' *********************************************************************************
'''' --> colComputer
Set colComputer = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem",,48)
For Each objComputer in colComputer
NumOfProc = S_3 & "Number Of Processors: " & objComputer.NumberOfProcessors
Comp = Split(objComputer.UserName,"\")
CompReport = S_3 & "Computer Name : " & Comp(0) & vbCrLf & S_3 & "User Name : " & Comp(1) &_
vbCrLf & vbCrLf & S_5 & "Mother Board Information"
Dim Ram : Ram = FormatNumber(objComputer.TotalPhysicalMemory / MB,1)
ComputerReport = CompReport & Vbcrlf & S_3 & "Total Physical Memory : " & Ram & " MB" &_
vbCrLf & S_3 & "Mother Board Model : " & objComputer.Model
Next
'''' *********************************************************************************
'''' --> Bios
Set Bios = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS",,48)
For Each objBios in Bios
BDate = Left(objBios.ReleaseDate,8)
BDate1 = Left(BDate,4) : BDate2 = Right(BDate,4)
BDate2a = Left(BDate2,2) : BDate3 = Right(BDate2,2)
BiosReportDate = "Bios Release Date : " & BDate1 & "-" & BDate2a & "-" & BDate3
BiosReportDate = S_3 & BiosReportDate & vbCrLf & S_3 &_
"Manufacturer : " & objBios.Manufacturer & vbCrLf & S_3 &_
"Bios Version : " & objBios.Version
Next
'''' *********************************************************************************
'''' --> Processor
Set Processor = objWMIService.ExecQuery( "SELECT * FROM Win32_Processor",,48)
For Each objProc in Processor
Proc = S_3 & "Processor Name : " & objProc.Name : Speed = S_3 & "Processor Speed : " & objProc.MaxClockSpeed & " MHZ"
ProcReport = S_5 & "Cpu Report" & vbCrLf & NumOfProc & vbCrLf & Proc & vbCrLf & Speed & vbCrLf
Next
'''' *********************************************************************************
'''' --> ObjHD
Set HardDrive = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive",,48)
For Each ObjHD In HardDrive
HDSize = ObjHD.Size / GB : HDS = Left(HDSize,5) : HDId = ObjHD.DeviceID : HDIid1 = Right(HDId,14)
HdName = HdName & vbcrlf & S_3 & "Hard Drive Model: " & ObjHD.Model & vbCrLf & S_3 & "Device ID: " & HDIid1 & vbCrLf &_
S_3 & "Hard Drive Size: " & HDS & vbcrlf & S_3 & "Number Of Partitions: " & ObjHD.Partitions & vbCrLf & Ln1
Next
'''' *********************************************************************************
'''' --> ObjPart
Set Partition = objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDisk where DriveType = 3")
For Each ObjPart In Partition
PSize = ObjPart.Size /GB : Ps = Left(PSize,5) : PFreeSpace = ObjPart.FreeSpace / GB : Pfs = Left(PFreeSpace,5)
UsedSpace = Ps - Pfs
If UsedSpace < 1 Then
PSize = ObjPart.Size /MB : Ps = Left(PSize,5)
PFreeSpace = ObjPart.FreeSpace / MB : Pfs = Left(PFreeSpace,5) : UsedSpace = Ps - Pfs : Us = Left(UsedSpace,5)
PReport = PReport & vbcrlf & S_3 & "This drive had less then a Gigabit of Used Space" &_
vbCrLf & S_3 & "Partition Letter: " & ObjPart.Name & Vbtab & "Volume Name: " & ObjPart.VolumeName & _
vbCrLf & S_3 & "Total Size: " & Ps & " MB" & vbCrLf & S_3 & "Free Space: " & Pfs & " MB" &_
vbCrLf & S_3 & "Used Space: " & US & " MB" & vbCrLf & S_3 & "File System: " & ObjPart.FileSystem & vbCrLf & Ln1
Else
PReport = PReport & vbcrlf & S_3 & "This drive had more then a Gigabit of Used Space" &_
vbCrLf & S_3 & "Partition Letter: " & ObjPart.Name & Vbtab & "Volume Name: " & ObjPart.VolumeName &_
vbCrLf & S_3 & "Size: " & Ps & " GB" & vbCrLf & S_3 & "FreeSpace: " & Pfs & " GB" &_
vbCrLf & S_3 & "Used space: " & UsedSpace & " GB" & vbCrLf & S_3 & "File System: " & ObjPart.FileSystem & vbCrLf & Ln1
End If
Next
'''' *********************************************************************************
'''' --> OsInfo
Set OsInfo = objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem",,48)
For Each objOs in OsInfo
BDate = Left(objOs.InstallDate,8)
BDate1 = Left(BDate,4) : BDate2 = Right(BDate,4)
BDate2a = Left(BDate2,2) : BDate3 = Right(BDate2,2)
InstallDate = "Install Date : " & BDate1 & "-" & BDate2a & "-" & BDate3
Ver = "-Build-" & objOs.BuildNumber : N1 = Split(objOs.Name,"|")
OsName = S_5 & "Operating System Name" & vbCrLf & S_3 & N1(0) & Ver & vbCrLf & S_3 & InstallDate & vbCrLf
Next
'''' *********************************************************************************
'''' --> Software **** MADE BY ROQUESPEAR
Set Software = objWMIService.ExecQuery("Select * from Win32_Product",,48)
For Each objSoftware in Software
SWName = S_3 & "Installed Software : " & objSoftware.Name
SWVer = S_3 & "Version : " & objSoftware.Version
InstalledSotware = InstalledSotware & vbCrLf & SWName & Vbcrlf & SWVer & vbCrLf & Ln1
Next
'''' *********************************************************************************
'''' TEXT FILE OUTPUT
Set Ts = Fso.CreateTextFile(FileReport)
Ts.WriteLine S_5 & Chr(171) & " ***** Computer Report " & Now() & " ***** " & Chr(187) & vbCrLf
Ts.WriteLine S_5 & "Computer Information" & vbCrLf & ComputerReport & vbCrLf & BiosReportDate & vbCrLf
Ts.WriteLine S_5 & "Hard Drive Information" & HdName & vbCrLf
Ts.WriteLine S_5 & "Parition Information" & PReport & vbCrLf
Ts.WriteLine ProcReport & vbCrLf & OsName
Ts.WriteLine S_5 & "SoftWare" & InstalledSotware
Ts.Close
Act.Run(Chr(34) & FileReport & Chr(34)),1,True
'''' *********************************************************************************
'''' KEEP OR DELETE FILE
Dim ZZ1
ZZ1 = Act.Popup("Did you want to keep the report" &_
vbCrLf & "Yes to keep the report" & vbCrLf & "No to delete the report" &_
vbCrLf & "If nothing is selected in One minute " &_
vbCrLf & "the default action is to keep the file",61,"Keep Or Delete", 4 + 32)
If ZZ1 = 7 Then Fso.DeleteFile(FileReport) End If

Link to comment
Share on other sites

thats fantastic! the output is excellent and very structured and easy to read! :D

one thing..... you need to take my name out of it, you deserve all the credit :thumbup

but seriously this is going to help so much if i can use it to audit entire networks in a single (or double click) lol

thank you

Link to comment
Share on other sites

Some questions

1:\ Is the output for the Computer, Bios, Processor, Hardrive, Partition, Operating System, Software is

this what you need?

2:\ Would you like me to try and add a what updates are installed on the computer, along with what service pack is installed?

3:\ Would the text format be good enough for what you need?

Link to comment
Share on other sites

Hi,

1) yes the info is perfect

2) i think just service packs will suffice, would u have the need for hotfixes installed? if i ever did have the need for this i would prob just use systeminfo from command prompt with the remote switch

3) from a programming point of view a text doucment is much easier, how would a text doc work when scanning multiple pc's? would it create a seperate one for each pc or put it all in one document?

thanks :D

EDIT: i had chance to read through your script and it makes it soooo much easier to read because its so organised, i have a much better understanding thanks to you :)

Edited by eyeball
Link to comment
Share on other sites

Yea GunSmokingMan always puts out nice clean code. It doesn't always look pretty in posts because of the way CODE tags handle indentations, but put it in PrimalScript or something similar and it looks great. Logical and easy to follow.

Link to comment
Share on other sites

RogueSpear and eyeball, Thanks for the nice comments on my coding abilities.

3) from a programming point of view a text doucment is much easier, how would a text doc work when scanning multiple pc's? would it create a seperate one for each pc or put it all in one document?
I guess you could script it to leave a text file for each computer it runs against in the network and leave it as a separate text file.

Example

For Each objComputer in colComputer 
NumOfProc = S_3 & "Number Of Processors: " & objComputer.NumberOfProcessors
Comp = Split(objComputer.UserName,"\")
CompReport = S_3 & "Computer Name : " & Comp(0) & vbCrLf & S_3 & "User Name : " & Comp(1) &_
vbCrLf & vbCrLf & S_5 & "Mother Board Information"
Dim Ram : Ram = FormatNumber(objComputer.TotalPhysicalMemory / MB,1)
ComputerReport = CompReport & Vbcrlf & S_3 & "Total Physical Memory : " & Ram & " MB" &_
vbCrLf & S_3 & "Mother Board Model : " & objComputer.Model
Dim FileReport : FileReport = DTop & "\" & Comp(0) & ".txt"
Next

If you wanted as singel text file with all the computer it ran against. There would have to be a few changes a made so it could break up each computer into section and list each individually.

2) i think just service packs will suffice, would u have the need for hotfixes installed? if i ever did have the need for this i would prob just use systeminfo from command prompt with the remote switch

I just wanted to make sure what you need in this, because it might help you check and see what updates are installed on each machine across a network.

Question

1:\ Would another WMI class to list hardware devices be needed in the script?

2:\ How about a defrag routine to be run on each computer in the network? This could use Microsoft built in disk defragger.

Link to comment
Share on other sites

RogueSpear and eyeball, Thanks for the nice comments on my coding abilities.

3) from a programming point of view a text doucment is much easier, how would a text doc work when scanning multiple pc's? would it create a seperate one for each pc or put it all in one document?

I guess you could script it to leave a text file for each computer it runs against in the network and leave it as a separate text file.

Example

For Each objComputer in colComputer 
NumOfProc = S_3 & "Number Of Processors: " & objComputer.NumberOfProcessors
Comp = Split(objComputer.UserName,"\")
CompReport = S_3 & "Computer Name : " & Comp(0) & vbCrLf & S_3 & "User Name : " & Comp(1) &_
vbCrLf & vbCrLf & S_5 & "Mother Board Information"
Dim Ram : Ram = FormatNumber(objComputer.TotalPhysicalMemory / MB,1)
ComputerReport = CompReport & Vbcrlf & S_3 & "Total Physical Memory : " & Ram & " MB" &_
vbCrLf & S_3 & "Mother Board Model : " & objComputer.Model
Dim FileReport : FileReport = DTop & "\" & Comp(0) & ".txt"
Next

If you wanted as singel text file with all the computer it ran against. There would have to be a few changes a made so it could break up each computer into section and list each individually.

2) i think just service packs will suffice, would u have the need for hotfixes installed? if i ever did have the need for this i would prob just use systeminfo from command prompt with the remote switch
I just wanted to make sure what you need in this, because it might help you check and see what updates are installed on each machine across a network.

Question

1:\ Would another WMI class to list hardware devices be needed in the script?

2:\ How about a defrag routine to be run on each computer in the network? This could use Microsoft built in disk defragger.

that code for the multiple text files is great, i think its the best way, i kinda liked the xls file the old script gave BUT it couldnt be run from a server as most servers dont have excel on, so text files is the way to go. :)

the thing about the hotfixes... i guess it would be useful now that i think about it... maybe it could give you the following:

service pack - 4

number of hotfixes - 13

instead of listing them all it could give you a number because if for example i scanned a pc with xp sp2 and it had 10 hotfixes, i would know (either from this forum or otherwise) that there are around 25-30 hotfixes missing. its just i think listing them all would take up a lot of space, unless you put them at the bottom of the text file?

yes a list of all hardware would be very good, instead of looking through the different sections. ill look into this and experiment a bit, i post again later when i find a suitable one.

the defrag is a good idea but would it add a scheduled task for this? or just run the defrag when the script is run?.... actually a totally seperate script that could remotely defrag would be awesome :) i might start on it..

no seriously we have to consider the implications of this.

thanks Gunsmokingman :)

EDIT:

ok iv looked at listing hardware and found there is no WMI that is capable of listing all hardware so using different WMI's to list each one individually and then putting them all together. i shall have a go at creating a script that outputs this to a text file and post back later

Edited by eyeball
Link to comment
Share on other sites

Try this script it out put is now a hta this may work on a server

Save As ReportComInfo.vbs

Dim strComputer : strComputer = "." 
'''' *********************************************************************************
'''' --> VARIBLES FOR THE WMI CLASSES
Dim objWMIService
Dim Computer, ObjComp , ObjCompHta
Dim Bios, objBios , objBiosHta
Dim OsInfo , objOs, objOsHta
Dim CpuInfo, objCPU , CpuInfoHta
'''' *********************************************************************************
'''' -->
Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim SD : SD = Act.ExpandEnvironmentStrings("%SystemDrive%")
Dim CName : CName = Act.ExpandEnvironmentStrings("%ComputerName%")
Dim FName : FName = (SD & "\" & CName & ".txt")
Dim UName : UName = Act.ExpandEnvironmentStrings("%UserName%")
'''' *********************************************************************************
'''' --> TEXT VARIBLES
Dim HtaStyle1, HtaStyle2, Ln1, S_3, S_5
HtaStyle1 = "font:8.75pt;font-family:Palatino Linotype;color:#000080;"
HtaStyle2 = "font:8.75pt;font-family:Palatino Linotype;color:#808080;"
HtaStyle1 = "<TD Style=""" & HtaStyle1 & """ Width=""125"">"
HtaStyle2 = "<TD Style=""" & HtaStyle2 & """ Width=""275"">"
S_5 = Space(5) : S_3 = Space(3) : Ln1 = Chr(171) & " --------------------------------- " & Chr(187)
'''' *********************************************************************************
'''' --> Varibles To Convert Size
Dim GB, MB : GB = 1024 * 1024 * 1024 : MB = 1024 * 1024
'''' *********************************************************************************
'''' --> Conver Wmi Date Format
Dim aDate, aDate1, aDate2, aDate2a, aDate3 '''' --> Conver Wmi Date Format
Dim BDate, BDate1, BDate2, BDate2a, BDate3 '''' --> Conver Wmi Date Format
'''' *********************************************************************************
'''' --> START THE WMI OBJECTS
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'''' *********************************************************************************
'''' --> WMI Bios CLASS
Set Bios = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS",,48) '''' --> START THE WMI Bios Class
'''' *********************************************************************************
'''' --> WMI Computer CLASS
Set Computer = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each ObjComp in Computer
Dim CpuCount: CpuCount = ObjComp.NumberOfProcessors
Dim Ram : Ram = FormatNumber(ObjComp.TotalPhysicalMemory / MB,1)
'''' --> HTA OUTPUT Computer
ObjCompHta = ("<TABLE Bgcolor="""" Style="""">" &_
"<TD Style=""font:8.75pt;font-family:Palatino Linotype;color:#000080;"" WIDTH=""450"">" &_
"<TABLE><TD Style=""font:10.75pt;font-family:Palatino Linotype;color:#009000;text-align:Center;"" WIDTH=""350"">" &_
"<B>Computer Information</B></TD></TABLE>" &_
"<TABLE>" & HtaStyle1 & "Logon On Name</TD>" &_
HtaStyle2 & UCase(UName)& "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "Computer Name</TD>" &_
HtaStyle2 & UCase(CName)& "</TD></TABLE>" & _
"<TABLE><TD Style=""font:10.75pt;font-family:Palatino Linotype;color:#009000;text-align:Center;"" WIDTH=""350"">" &_
"<B>Mother Board Information</B></TD></TABLE>" &_
"<TABLE>" & HtaStyle1 & "Manufacturer</TD>" &_
HtaStyle2 & UCase(ObjComp.Manufacturer) & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "Description</TD>" &_
HtaStyle2 & UCase(ObjComp.Description) & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "Model</TD>" &_
HtaStyle2 & UCase(ObjComp.Model) & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "Installed Ram</TD>" &_
HtaStyle2 & Ram & " MB" & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "SystemType</TD>" &_
HtaStyle2 & UCase(ObjComp.SystemType) & "</TD></TABLE>" & _
"</TD></TABLE>")
Next '''' --> ENDS THE Computer WMI OBJECT
'''' *********************************************************************************
'''' --> WMI Bios CLASS
Set Bios = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS",,48) '''' --> START THE WMI Bios Class
For Each objBios in Bios
BDate = Left(objBios.ReleaseDate,8)
BDate1 = Left(BDate,4) : BDate2 = Right(BDate,4)
BDate2a = Left(BDate2,2) : BDate3 = Right(BDate2,2)
'''' --> HTA OUTPUT objBios
objBiosHta = ("<TABLE Bgcolor="""" Style="""">" &_
"<TD Style=""font:8.75pt;font-family:Palatino Linotype;color:#000080;"" WIDTH=""450"">" &_
"<TABLE><TD Style=""font:10.75pt;font-family:Palatino Linotype;color:#009000;text-align:Center;"" WIDTH=""350"">" &_
"<B>Bios Information</B></TD></TABLE>" &_
"<TABLE>" & HtaStyle1 & "Bios Release Date</TD>" &_
HtaStyle2 & BDate1 & "-" & BDate2a & "-" & BDate3 & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "Bios By</TD>" &_
HtaStyle2 & UCase(objBios.Manufacturer) & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "Bios Version</TD>" &_
HtaStyle2 & UCase(objBios.Version) & "</TD><TABLE>" &_
"</TD></TABLE>")
Next '''' --> ENDS THE Bios WMI OBJECT
'''' *********************************************************************************
'''' --> WMI OsInfo CLASS
Set OsInfo = objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem",,48)
For Each objOs in OsInfo
aDate = Left(objOs.InstallDate,8)
aDate1 = Left(aDate,4) : aDate2 = Right(aDate,4)
aDate2a = Left(aDate2,2) : aDate3 = Right(aDate2,2)
Dim N1 : N1 = Split(objOs.Name,"|")
'''' --> HTA OUTPUT OsInfo
objOsHta = ("<TABLE Bgcolor="""" Style="""">" &_
"<TD Style=""font:8.75pt;font-family:Palatino Linotype;color:#000080;"" WIDTH=""450"">" &_
"<TABLE><TD Style=""font:10.75pt;font-family:Palatino Linotype;color:#009000;text-align:Center;"" WIDTH=""350"">" &_
"<B>Operating System Information</B></TD></TABLE>" &_
"<TABLE>" & HtaStyle1 & "OS Name</TD>" &_
HtaStyle2 & UCase(N1(0)) & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "OS Version</TD>" &_
HtaStyle2 & UCase(objOs.Version) & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "OS Installed Date</TD>" &_
HtaStyle2 & aDate1 & "-" & aDate2a & "-" & aDate3 & "</TD></TABLE>" & _
"</TD></TABLE>")
Next '''' --> ENDS THE OsInfo WMI OBJECT
'''' *********************************************************************************
'''' --> WMI CpuInfo CLASS
Set CpuInfo = objWMIService.ExecQuery( "SELECT * FROM Win32_Processor",,48)
For Each objCPU in CpuInfo
'''' --> HTA OUTPUT CpuInfo
CpuInfoHta = ("<TABLE Bgcolor="""" Style="""">" &_
"<TD Style=""font:8.75pt;font-family:Palatino Linotype;color:#000080;"" WIDTH=""450"">" &_
"<TABLE><TD Style=""font:10.75pt;font-family:Palatino Linotype;color:#009000;text-align:Center;"" WIDTH=""350"">" &_
"<B>CPU Information</B></TD></TABLE>" &_
"<TABLE>" & HtaStyle1 & "Manufacturer</TD>" &_
HtaStyle2 & UCase(objCPU.Manufacturer) & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "Processor Name</TD>" &_
HtaStyle2 & UCase(objCPU.Name) & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "Number Of CPU`s</TD>" &_
HtaStyle2 & CpuCount & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "Cpu Details</TD>" &_
HtaStyle2 & UCase(objCPU.Description) & "</TD><TABLE>" &_
"<TABLE>" & HtaStyle1 & "Processor Speed</TD>" &_
HtaStyle2 & objCPU.MaxClockSpeed & " MHZ" & "</TD></TABLE>" & _
"<TABLE>" & HtaStyle1 & "L2 Cache Size</TD>" &_
HtaStyle2 & objCPU.L2CacheSize & "</TD><TABLE>" &_
"<TABLE>" & HtaStyle1 & "L2 Cache Speed</TD>" &_
HtaStyle2 & objCPU.L2CacheSpeed & " MHZ" & "</TD><TABLE>" &_
"</TD></TABLE>")
Next '''' --> ENDS THE CpuInfo WMI OBJECT
'''' *********************************************************************************
'''' --> MAKE AND START THE HTA
Dim MkHta : MkHta = SD & "\ComputerInfo_V1.Hta"
Dim Ts : Set Ts = Fso.CreateTextFile(MkHta)
Ts.WriteLine S_3 & "<script language=javascript>" & vbCrLf &_
"window.resizeTo (535,791), window.moveTo (250,75);" & vbCrLf & "</SCRIPT>"
Ts.WriteLine S_3 & "<Body BgColor=""#eeeeee""><Center>"
Ts.WriteLine S_3 & ObjCompHta
Ts.WriteLine S_3 & objOsHta
Ts.WriteLine S_3 & objBiosHta
Ts.WriteLine S_3 & CpuInfoHta
Ts.Close
Act.Run(MkHta),1,True : Fso.DeleteFile(MkHta)

Edited by gunsmokingman
Link to comment
Share on other sites

I just have it delete because I have not added all the WMI classes to it yet. There is a couple of more left

to add. When they are all added then I will have it ask the keep or delete question.

If you do not want to delete this file then change this line

Act.Run(MkHta),1,True : Fso.DeleteFile(MkHta)

To This

Act.Run(MkHta),1,True

Link to comment
Share on other sites

I have added this Hard drive And Partition WMI Class and a check for what Service Pack and Updates that are installed. I will be adding these to it next Software, HardWare, Network. Could You Check and see if you like how I have the HTA disply, also it still deletes itself.

Save As ReportComInfo.vbs

Dim strComputer : strComputer = "." 
'''' *********************************************************************************
'''' --> VARIBLES FOR THE WMI CLASSES
Dim objWMIService
'''' *********************************************************************************
'''' --> OBJECTS FOR SCRIPT
Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim SD : SD = Act.ExpandEnvironmentStrings("%SystemDrive%")
Dim CName : CName = Act.ExpandEnvironmentStrings("%ComputerName%")
Dim FName : FName = (SD & "\" & CName & ".txt")
Dim UName : UName = Act.ExpandEnvironmentStrings("%UserName%")
'''' *********************************************************************************
'''' --> TEXT VARIBLES
Dim HtaStyle1, HtaStyle2, Ln1, S_3, S_5 , Table1,TdBig, TdSmall
HtaStyle1 = "font:8.75pt;font-family:Palatino Linotype;color:#000080;"
HtaStyle2 = "font:8.75pt;font-family:Palatino Linotype;color:#808080;"
HtaStyle1 = "<TD Style=""" & HtaStyle1 & """ Width=""135""><B> "
HtaStyle2 = "<TD Style=""" & HtaStyle2 & """ Width=""275""><B> "
TdBig = "<TD Style=""font:8.75pt;font-family:Palatino Linotype;color:#000080;text-align:CENTER; "" WIDTH=""450"">"
TdSmall = "<TD Style=""font:8.75pt;font-family:Palatino Linotype;color:#009000;text-align:CENTER;"" WIDTH=""350"">"
Table1 = "<TABLE BORDER=""1"">"
S_5 = Space(5) : S_3 = Space(3) : Ln1 = Chr(171) & " --------------------------------- " & Chr(187)
'''' *********************************************************************************
'''' --> Varibles To Convert Size
Dim GB, MB : GB = 1024 * 1024 * 1024 : MB = 1024 * 1024
'''' *********************************************************************************
'''' --> Conver Wmi Date Format
Dim aDate, aDate1, aDate2, aDate2a, aDate3 '''' --> Conver Wmi Date Format
Dim BDate, BDate1, BDate2, BDate2a, BDate3 '''' --> Conver Wmi Date Format
'''' *********************************************************************************
'''' --> START THE WMI OBJECTS
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'''' *********************************************************************************
'''' --> WMI Computer CLASS
Dim Computer, ObjComp , ObjCompHta
Set Computer = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each ObjComp in Computer
Dim CpuCount: CpuCount = ObjComp.NumberOfProcessors
Dim Ram : Ram = FormatNumber(ObjComp.TotalPhysicalMemory / MB,1)
'''' --> HTA OUTPUT Computer
ObjCompHta = ("<TABLE Bgcolor="""" Style="""">" & TdBig & Table1 & TdSmall &_
"<B>Computer Information</B></TD></TABLE>" &_
Table1 & HtaStyle1 & "Logon On Name</TD>" &_
HtaStyle2 & UCase(UName)& "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Computer Name</TD>" &_
HtaStyle2 & UCase(CName)& "</TD></TABLE>" & _
"<TABLE Bgcolor="""" Style="""">" & TdBig & Table1 & TdSmall &_
"<B>Mother Board Information</B></TD></TABLE>" &_
Table1 & HtaStyle1 & "Manufacturer</TD>" &_
HtaStyle2 & UCase(ObjComp.Manufacturer) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Description</TD>" &_
HtaStyle2 & UCase(ObjComp.Description) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Model</TD>" &_
HtaStyle2 & UCase(ObjComp.Model) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Installed Ram</TD>" &_
HtaStyle2 & Ram & " MB" & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "SystemType</TD>" &_
HtaStyle2 & UCase(ObjComp.SystemType) & "</TD></TABLE>" & _
"</TD></TABLE>")
Next '''' --> ENDS THE Computer WMI OBJECT
'''' *********************************************************************************
'''' --> WMI Bios CLASS
Dim Bios, objBios , objBiosHta
Set Bios = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS",,48) '''' --> START THE WMI Bios Class
For Each objBios in Bios
BDate = Left(objBios.ReleaseDate,8)
BDate1 = Left(BDate,4) : BDate2 = Right(BDate,4)
BDate2a = Left(BDate2,2) : BDate3 = Right(BDate2,2)
Dim BiosDate : BiosDate = BDate1 & "-" & BDate2a & "-" & BDate3
'''' --> HTA OUTPUT objBios
objBiosHta = ("<TABLE Bgcolor="""" Style="""">" & TdBig & Table1 & TdSmall &_
"<B>Bios Information</B></TD></TABLE>" &_
Table1 & HtaStyle1 & "Bios Release Date</TD>" & HtaStyle2 & BiosDate & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Bios Made By</TD>" & HtaStyle2 & UCase(objBios.Manufacturer) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Bios Version</TD>" & HtaStyle2 & UCase(objBios.Version) & "</TD></TABLE>" & _
"</TD></TABLE>")
Next '''' --> ENDS THE Bios WMI OBJECT
'''' *********************************************************************************
'''' --> WMI OsInfo CLASS
Dim OsInfo , objOs, objOsHta
Set OsInfo = objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem",,48)
For Each objOs in OsInfo
aDate = Left(objOs.InstallDate,8)
aDate1 = Left(aDate,4) : aDate2 = Right(aDate,4)
aDate2a = Left(aDate2,2) : aDate3 = Right(aDate2,2)
Dim WinDate, N1, ServicePack : N1 = Split(objOs.Name,"|")
ServicePack = UCase(objOs.CSDVersion)
WinDate = aDate1 & "-" & aDate2a & "-" & aDate3
'''' --> HTA OUTPUT OsInfo
objOsHta = ("<TABLE Bgcolor="""" Style="""">" & TdBig & Table1 & TdSmall &_
"<B>Operating System Information</B></TD></TABLE>" &_
Table1 & HtaStyle1 & "OS Name</TD>" & HtaStyle2 & UCase(N1(0)) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "OS Version</TD>" & HtaStyle2 & UCase(objOs.Version) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "OS Install Date</TD>" & HtaStyle2 & WinDate & "</TD></TABLE>" & _
"</TD></TABLE>")
Next '''' --> ENDS THE OsInfo WMI OBJECT
'''' *********************************************************************************
'''' --> REPORT FOR SERVICE PACK AND UPDATES
Dim Kbreport, KblUp, ObjUp, ObjKB, Spinfo, UpKB, RptKB, KBL , Cnt, Rpl1
Dim objSession : Set objSession = CreateObject("Microsoft.Update.Session")
Dim objSearcher : Set objSearcher = objSession.CreateUpdateSearcher
Dim objResults : Set objResults = objSearcher.Search("Type='Software'")
Dim colUpdates : Set colUpdates = objResults.Updates
Spinfo = ("<TABLE Bgcolor="""" Style="""">" & TdBig & Table1 & TdSmall &_
"<B>Service Pack Information</B></TD></TABLE>" & Table1 & HtaStyle1 &_
"Service Pack Installed</TD>" & HtaStyle2 & ServicePack & "</TD></TABLE>")
For i = 0 to colUpdates.Count - 1
Rpl1 = colUpdates.Item(i).Title
If InStr(Rpl1,"Security Update") Then
Cnt = colUpdates.Count
KBL = Replace(Rpl1,"Security Update for Windows XP","XP")
KblUp = Replace(KBL,"Security Update for"," ")
ObjKB = Replace(KblUp,"for Windows XP","XP")
UpKB = Replace(ObjKB,"Microsoft .NET Framework, Version 1.1 Service Pack 1","Ms.NetFrameWork-Ver-1.1-SP1")
RptKB = UpKB
ObjKblUpHta = ObjKblUpHta & Table1 & HtaStyle1 & "Security Update Name</TD>" & HtaStyle2 & RptKB & "</TD></TABLE>"
End If
Next
Spinfo = Spinfo & vbCrLf & ("<TABLE Bgcolor="""" Style="""">" & TdBig &_
Table1 & TdSmall & "<B>Installed Security Updates Total = " & Cnt & "</B></TD></TABLE>" &_
Table1 & TdSmall & "<B>This does not include Languages Updates</B></TD></TABLE>")
Kbreport = (Spinfo & vbCrLf & ObjKblUpHta & "</TD></TABLE>")
'''' *********************************************************************************
'''' --> WMI CpuInfo CLASS
Dim CpuInfo, objCPU , CpuInfoHta
Set CpuInfo = objWMIService.ExecQuery( "SELECT * FROM Win32_Processor",,48)
For Each objCPU in CpuInfo
'''' --> HTA OUTPUT CpuInfo
CpuInfoHta = ("<TABLE Bgcolor="""" Style="""">" & TdBig & Table1 & TdSmall &_
"<B>CPU Information</B></TD></TABLE>" &_
Table1 & HtaStyle1 & "Manufacturer</TD>" &_
HtaStyle2 & UCase(objCPU.Manufacturer) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Processor Name</TD>" &_
HtaStyle2 & UCase(objCPU.Name) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Number Of CPU`s</TD>" &_
HtaStyle2 & CpuCount & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Cpu Details</TD>" &_
HtaStyle2 & UCase(objCPU.Description) & "</TD></TABLE>" &_
Table1 & HtaStyle1 & "Processor Speed</TD>" &_
HtaStyle2 & objCPU.MaxClockSpeed & " MHZ" & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "L2 Cache Size</TD>" &_
HtaStyle2 & objCPU.L2CacheSize & "</TD></TABLE>" &_
Table1 & HtaStyle1 & "L2 Cache Speed</TD>" &_
HtaStyle2 & objCPU.L2CacheSpeed & " MHZ" & "</TD></TABLE>" &_
"</TD></TABLE>")
Next '''' --> ENDS THE CpuInfo WMI OBJECT
'''' *********************************************************************************
'''' --> WMI HDinfo CLASS
Dim HDinfo, ObjHD, HDinfoHta
Set HDinfo = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive",,48)
For Each ObjHD In HDinfo
Dim HDS, HDId : HDS = Left(ObjHD.Size / GB,5) : HDId = Right(ObjHD.DeviceID,14)
'''' --> HTA OUTPUT HDinfoHta
HDinfoHta = HDinfoHta & ("<TABLE Bgcolor="""" Style="""">" & TdBig & Table1 & TdSmall &_
"<B>Hard Drive Information</B></TD></TABLE>" &_
Table1 & HtaStyle1 & "Hard Drive Model</TD>" &_
HtaStyle2 & UCase(ObjHD.Model) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Device ID</TD>" &_
HtaStyle2 & UCase(HDId) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Hard Drive Size</TD>" &_
HtaStyle2 & HDS & " GB" & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Number Of Partitions</TD>" &_
HtaStyle2 & ObjHD.Partitions & "</TD></TABLE>" &_
"</TD></TABLE>")
Next '''' --> ENDS THE HDinfo WMI OBJECT
'''' *********************************************************************************
'''' --> WMI Partition CLASS
Dim Partition , ObjPart, PartitionHta
Set Partition = objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDisk where DriveType = 3")
For Each ObjPart In Partition
Dim Pfs, Ps, UsedSpace,Small, Large
Ps = Left(ObjPart.Size /GB,5) : Pfs = Left(ObjPart.FreeSpace / GB,5) : UsedSpace = Ps - Pfs
If UsedSpace < 1 Then
Ps = Left(ObjPart.Size /MB,5): Pfs = Left(ObjPart.FreeSpace / MB ,5) : UsedSpace = Ps - Pfs : Small = Left(UsedSpace,5)
PartitionHta = PartitionHta & ("<TABLE Bgcolor="""" Style="""">" & TdBig & Table1 & TdSmall &_
"<B>Partition Information Less then a Gigabit of Used Space</B></TD></TABLE>" &_
Table1 & HtaStyle1 & "Partition Letter</TD>" &_
HtaStyle2 & ObjPart.Name & "\" & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Volume Name</TD>" &_
HtaStyle2 & UCase(ObjPart.VolumeName) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Total Size</TD>" &_
HtaStyle2 & Ps & " MB" & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Free Space</TD>" &_
HtaStyle2 & Pfs & " MB" & "</TD></TABLE>" &_
Table1 & HtaStyle1 & "Used Space</TD>" &_
HtaStyle2 & Small & " MB" & "</TD></TABLE>" &_
Table1 & HtaStyle1 & "File System</TD>" &_
HtaStyle2 & UCase(ObjPart.FileSystem)& "</TD></TABLE>" &_
"</TD></TABLE>")
Else
Large = Left(UsedSpace,5)
PartitionHta = PartitionHta & ("<TABLE Bgcolor="""" Style="""">" & TdBig & Table1 & TdSmall &_
"<B>Partition Information More then a Gigabit of Used Space</B></TD></TABLE>" &_
Table1 & HtaStyle1 & "Partition Letter</TD>" &_
HtaStyle2 & ObjPart.Name & "\" & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Volume Name</TD>" &_
HtaStyle2 & UCase(ObjPart.VolumeName) & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Total Size</TD>" &_
HtaStyle2 & Ps & " GB" & "</TD></TABLE>" & _
Table1 & HtaStyle1 & "Free Space</TD>" &_
HtaStyle2 & Pfs & " GB" & "</TD></TABLE>" &_
Table1 & HtaStyle1 & "Used Space</TD>" &_
HtaStyle2 & Large & " GB" & "</TD></TABLE>" &_
Table1 & HtaStyle1 & "File System</TD>" &_
HtaStyle2 & UCase(ObjPart.FileSystem)& "</TD></TABLE>" &_
"</TD></TABLE>")
End If
Next '''' --> ENDS THE Partition WMI OBJECT
'''' *********************************************************************************
'''' --> MAKE AND START THE HTA
Dim MkHta : MkHta = SD & "\ComputerInfo_V1.Hta"
Dim Ts : Set Ts = Fso.CreateTextFile(MkHta)
Ts.WriteLine S_3 & "<script language=javascript>" & vbCrLf &_
"window.resizeTo (535,791), window.moveTo (250,75);" & vbCrLf & "</SCRIPT>"
Ts.WriteLine S_3 & "<Body BgColor=""#eeeeee"" Style=""font:10.75pt;font-family:Palatino Linotype;color:#101010;"">" &_
"<CENTER><B>" & CName & Ucase(" Information")
Ts.WriteLine S_3 & ObjCompHta
Ts.WriteLine S_3 & objOsHta
Ts.WriteLine S_3 & Kbreport
Ts.WriteLine S_3 & objBiosHta
Ts.WriteLine S_3 & CpuInfoHta
Ts.WriteLine S_3 & HDinfoHta
Ts.WriteLine S_3 & PartitionHta
Ts.Close
Act.Run(MkHta),1,True : Fso.DeleteFile(MkHta)

Edited by gunsmokingman
Link to comment
Share on other sites

:thumbup

Gunsmokingman that is awesome!

the hard drive information reports the physical hard disks and then you have the partition information showing the logical disks! just wow :w00t:

also the new look of the output is great! it looks rather professional if you dont mind my saying so :)

i think from that output there would be no need for a section that gives you a list of all hardware, its all there within the output anyway and since its so nicely structured its no problem to find it if you ever needed too.

thanks Gsm you are too B) cool!

Link to comment
Share on other sites

I have added to the script, it now makes 3 buttons in the HTA the function of the button are

1:\ Clean manager

2:\ Defrag a drive, this ask if you want to defrag the drive

3:\ Clean Mangager and Defrag this run both with out user intervention

This now ask if you want to delete the hta now

Save As SystemReport.vbs

Updated HTA SFX SystemReport_V3

Removed as not updating this, I have made it a vbs, all you have to do is change

this SystemReport.vbs.txt to SystemReport.vbs, this is a winrar file.

Link to SystemReport.vbs.rar

Edited by gunsmokingman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...