eyeball Posted April 10, 2006 Share Posted April 10, 2006 Hi all,i have a .vbs script that can audit an ip range and collect data. it collects such things as the operating system, RAM etc.basically i want to add in another WMI called win32_SoftwareFeature and use the value "ProductName" to tell me what software is installed on the machinethe .vbs script exports what it finds to an excel file i have been trying to do this almost all day and failed miserably lol please i know someone will find this a walk in the park, can anyone help me add this in?below is a link to the scripthttp://www.megaworm.com/images/./data/media/4/auditor.zipmany thanks Link to comment Share on other sites More sharing options...
RogueSpear Posted April 10, 2006 Share Posted April 10, 2006 It's going to take me a little while to look over all that code and put it what you're looking for, but FWIW there's some pretty kick a** stuff in that script. It'll certainly teach me a thing or two while trying to solve your problem. Link to comment Share on other sites More sharing options...
eyeball Posted April 10, 2006 Author Share Posted April 10, 2006 cool thanks for looking yes its a very very useful script indeed and i have learnt loads from just reading through it and experimentingunfortunatly im not good with arrays and its what (i assume) i need to implement software audits within this script. so if you could help me roguespear i would be very grateful Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 10, 2006 Share Posted April 10, 2006 I have been looking at the script and it is pretty messed up here is One example ofwhat I have found incorrectYou have this Two times and no Close for it.This is at Line 39 and Line 61 in the script.set fx = fsox.OpenTextFile(outputFile, ForWriting, True)Here is what I have made for you to work with'''' ***** - SCRIPT BY GUNSMOKINGMAN - ***** '''''''' ***** - http://gunsmokingman.ath.cx/ - ***** '''' strComputer = "." '''' ********************************************************************************* '''' VARIBLES FOR THE SCRIPT Dim ComputerReport, Comp, CompReport '''' --> colComputer Dim BDate, BiosReportDate '''' --> Bios Dim OsName, N1, Ver '''' --> OsInfo'''' ********************************************************************************* Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colComputer = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem",,48) Set Bios = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS",,48) Set Os = objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem",,48) '''' ********************************************************************************* '''' --> colComputer For Each objComputer in colComputer Comp = Split(objComputer.UserName,"\") CompReport = "Computer Name : " & Comp(0) & vbCrLf & "User Name : " & Comp(1) MB = 1024 * 1024 : Ram = FormatNumber(objComputer.TotalPhysicalMemory / MB,1) ComputerReport = CompReport & Vbcrlf & "Total Physical Memory : " & Ram & " MB" &_ vbCrLf & "Model : " & objComputer.Model Next'''' ********************************************************************************* '''' --> Bios For Each objBios in Bios BDate = Left(objBios.ReleaseDate,8) : DateBios BiosReportDate = BiosReportDate & vbCrLf & "Manufacturer : " & objBios.Manufacturer & vbCrLf &_ "Bios Version : " & objBios.Version Next'''' ********************************************************************************* '''' --> OsInfoSet OsInfo = objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem",,48) For Each objOs in OsInfo Ver = "-Build-" & objOs.BuildNumber : N1 = Split(objOs.Name,"|") OsName = "Operating System Name : " & vbCrLf & N1(0) & Ver Next'''' ********************************************************************************* '''' CONVERTS THE BIOS DATE FORMAT Function DateBios BDate1 = Left(BDate,4) : BDate2 = Right(BDate,4) BDate2a = Left(BDate2,2) : BDate3 = Right(BDate2,2) BiosReportDate = "Bios Release Date : " & BDate1 & "-" & BDate2a & "-" & BDate3 End Function '''' *********************************************************************************MsgBox ComputerReport & vbCrLf & BiosReportDate & vbCrLf & OsName, 0 + 32, "Computer Information"I will repost some more in the next couple of days if you want. I am not a coder but I will try my best to get it working properly for you. Link to comment Share on other sites More sharing options...
eyeball Posted April 11, 2006 Author Share Posted April 11, 2006 thanks GunSmokingMan thats great start, certainly is more organised but you cut the best part of the script! - the output to a .xls, unless you were going to implement this later?anyway that definately gives me something to work on, and im confident i could add more WMI's in there, the only thing i would have trouble with would be arrays like i say.thanks for the help Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 11, 2006 Share Posted April 11, 2006 I will be working on adding the .xls, I am working on getting it more orginised. Link to comment Share on other sites More sharing options...
RogueSpear Posted April 11, 2006 Share Posted April 11, 2006 (edited) basically i want to add in another WMI called win32_SoftwareFeature and use the value "ProductName" to tell me what software is installed on the machineI think I'll just let GSM handle this one as he seems to be actively working on it now. What I was going to implement was something using Win32_Product instead of Win32_SoftwareFeature. I just wrote this script yesterday for someone in a different forum:Option ExplicitDim ws, fs, strComputer, objWMIService, colSoftware, objSoftwareSet ws = WScript.CreateObject("WScript.Shell")Set fs = CreateObject("Scripting.FileSystemObject")strComputer = "."Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colSoftware = objWMIService.ExecQuery("Select * from Win32_Product")For Each objSoftware in colSoftware If Left(objSoftware.Name, 12) = "Adobe Reader" Then WScript.Echo objSoftware.Name & " is installed." WScript.Echo "The installed version is: " & objSoftware.Version End IfNext Edited April 11, 2006 by RogueSpear Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 11, 2006 Share Posted April 11, 2006 Hey RoqueSpear any help from you would be appreciated, I used what you posted in this script.This now produces a text file with all the information in it. I will be adding more of the WMI classesI just want to make sure this is the information you want to collect.'''' ***** - SCRIPT BY GUNSMOKINGMAN, ROQUESPEAR - ***** '''''''' ***** - http://gunsmokingman.ath.cx/ - ***** '''' Dim strComputer : strComputer = "." '''' ********************************************************************************* '''' VARIBLES FOR THE SCRIPT Dim colComputer, objComputer, ComputerReport, Comp, CompReport '''' --> colComputer Dim Bios, objBios, BiosDate, BiosReportDate '''' --> Bios Dim objProc, Processor, Proc, ProcReport, Speed '''' --> Processor Dim IDate, InstallDate, OsName, N1, Ver '''' --> OsInfo Dim InstalledSotware, Software, SWName, SWVer '''' --> Software Dim BDate, BDate1, BDate2, BDate2a, BDate3 '''' Conver Wmi Date Format Dim Ts , S_3, S_5 '''' --> Text Output S_3 = Space(3) : S_5 = Space(5) '''' Space Varibles'''' ********************************************************************************* '''' 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")'''' ********************************************************************************* Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")'''' ********************************************************************************* '''' --> colComputer Set colComputer = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem",,48) For Each objComputer in colComputer Comp = Split(objComputer.UserName,"\") CompReport = S_3 & "Computer Name : " & Comp(0) & vbCrLf & S_3 & "User Name : " & Comp(1) MB = 1024 * 1024 : Ram = FormatNumber(objComputer.TotalPhysicalMemory / MB,1) ComputerReport = CompReport & Vbcrlf & S_3 & "Total Physical Memory : " & Ram & " MB" &_ vbCrLf & S_3 & "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 & Proc & vbCrLf & Speed & vbCrLf 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 & S_3 & Chr(171) & " ------------ " & Chr(187) Next'''' ********************************************************************************* '''' TEXT FILE OUTPUT Set Ts = Fso.CreateTextFile(DTop & "\ComputerReport.txt") 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 ProcReport & vbCrLf & OsName Ts.WriteLine S_5 & "SoftWare" & InstalledSotware Ts.Close Act.Run(Chr(34) & DTop & "\ComputerReport.txt" & Chr(34)) Link to comment Share on other sites More sharing options...
eyeball Posted April 11, 2006 Author Share Posted April 11, 2006 thanks for the help RogueSpear much appreciated and gunsmokingman im sorry i didnt mean to sound rude when i said you left out the best bit im glad you are putting in and glad you are having a look at the script, i hope you find it of some use to you in the future Link to comment Share on other sites More sharing options...
RogueSpear Posted April 11, 2006 Share Posted April 11, 2006 @GSM, very nice work there If you run into something you want me to take a look at, please let me know. I'm pretty beyond busy right now with too many things going on. Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 12, 2006 Share Posted April 12, 2006 Eyeball could you list what you need for the Computer Info, I want to collect all information then we can try and get the Xls stuff to work. Could you give the newest posted script a try and tell me if it suitable for you.RoqueSpear if you need any help for your projects I may be able to help. Link to comment Share on other sites More sharing options...
eyeball Posted April 12, 2006 Author Share Posted April 12, 2006 (edited) hi Gsm ok that sounds like a good idea, this list will just be a basic one, if you can think of any more WMI's to add in that would be useful then please add them . ok heres the list with the value and the WMI class it comes from:pc hostname - win32_NetworkAdapterConfigurationdomain + role- win32_computerSystemProductMake, Model + Serial Number - win32_computerSystemProductTotal Ram - from Win32_logicalMemoryConfiguration****also would be nice to know how many memory slots the board has and which ones are used and which ones are empty cpu-z can do this and i dont know howOS + ServicePacks - from win32_OperatingSystemBios Revision - from win32_Bios or win32_systembiosProcessor Type - Win32_Processor***dual core show up as 2 cpu's, and i cant find a way around this****logged in user - win32_computersystemNIC Model (1-4) - win32_NetworkAdaptersn mask, d g/w, IP, MAC address - win32_NetworkAdapterConfigurationHdd space + names + number - win32_DiskDrivealso win32_DiskDrivePhysicalMedia tells you the number of physical disks in a systemPartition Info for each disk drive - win32_DiskPartition (shows partitions and their sizes! - v useful)page file location+ size could be useful - win32_pagefilescsi controller make model - win32_scsiController - v useful for serversshow tapedrive make + model - again useful for servers found from win32_tapedrivethats all Gsm hope this isnt too much, and if theres anything i can try to help with i willthank you so much hopefully almost everyone on the board will find a use for the final script and not just us two Edited April 12, 2006 by eyeball Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 12, 2006 Share Posted April 12, 2006 Ok i will see what I can do, I will post some thing here in a couple of hours.Did you get a chance to try the new script I posted. Link to comment Share on other sites More sharing options...
RogueSpear Posted April 12, 2006 Share Posted April 12, 2006 Programs like CPU-Z, Motherboard Monitor, etc are not using WMI for the reporting. I'm not sure exactly what it is that they're doing, but you'll probably notice that programs like that need to be continually updated as new chipset and motherboards are released. Link to comment Share on other sites More sharing options...
eyeball Posted April 12, 2006 Author Share Posted April 12, 2006 yeah i did try that new one Gsm and its great i cant wait for the full one!also rougespear i noticed that too as i had a win 2000 server that cpu z couldnt detect the motherboard as it was too old but through WMI i could get it, so im not exactly sure what it uses Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now