JSThePatriot Posted July 19, 2006 Posted July 19, 2006 (edited) When I first visit a new client, I take inventory of their machines, what is on them, stats, and other useful information. Up till now I would either write the information down, or just try to remember it myself. Then I decided why not write a script that would allow me to gather all this useful information, and put it in a format that I can understand and possibly print. I created that program (its even listed in this thread).I then expounded on my ideas, and have created this great Computer Information Library. Feel free to use it as you see fit, but please credit when you use one of my functions.Keywords: CompInfo, CompInfo.au3, Library, Computer, Computers, Info, Information, WMI, Windows Management InstrumentationRequires: AutoIt v3.2 + or AutoIt Beta v3.2.1.2+Software UDFs_ComputerGetStartup_ComputerGetSoftware_ComputerGetUsers_ComputerGetGroups_ComputerGetServices_ComputerGetThreads_ComputerGetProcesses_ComputerGetOSs_ComputerGetShares_ComputerGetEventLogs_ComputerGetBootConfig_ComputerGetExtensions_ComputerGetDesktops_ComputerGetDependentServices_ComputerGetPrintJobs_ComputerGetLoggedOnUsersHardware UDFs_ComputerGetDrives_ComputerGetPrinters_ComputerGetProcessors_ComputerGetBIOS_ComputerGetSoundCards_ComputerGetVideoCards_ComputerGetKeyboard_ComputerGetMouse_ComputerGetSystemProduct_ComputerGetNetworkCards_ComputerGetSystem_ComputerGetMonitors_ComputerGetMotherboard_ComputerGetBattery_ComputerGetMemoryI have finally created an include file with the above listed UDF's. I will be continually adding to this file.Include File:CompInfo.au3 | 1671 Previous Downloads (Total)Example File:CompInfoExamples.au3 | 929 Previous Downloads (Total)I have listed special thanks in the include file. Please note all example code will now start with #include "CompInfo.au3".I am working on adding error checking and standardizing the code. (Note: I haven't spent much time doing this as of late)NerdFencer has created a set of Drive UDF's that were inspired from this code. If you need more drive information please see his thread. ?do=embed' frameborder='0' data-embedContent>Edit 01: Added _ComputerGetPrintersEdit 02: Added _ComputerGetCPUsEdit 03: Changed _DriveGetInfo to _ComputerGetDrivesEdit 04: Updated _ComputerGetDrives with documentation and error checking.Edit 05: Fixed _ComputerGetUsers @ComputerName wasnt being used properly.Edit 06: Added _ComputerGetGroupsEdit 07: Updated _ComputerGet Printers/Groups with documentation and error checking.Edit 08: Changed _ComputerGetUsers to include more information. Updated _ComputerGetUsers with documentation and error checking.Edit 09: Changed _ComputerGetStartup to include more information. Updated _ComputerGetStartup with documentation and error checking.Edit 10: Added _ComputerGetServicesEdit 11: Added to the top of the post about requiring AutoIt's Beta version.Edit 12: Added _ComputerGetBIOSEdit 13: Added _ComputerGetThreadsEdit 14: Changed _ComputerGetCPUs to _ComputerGetProcessors and included more information.Edit 15: Added _ComputerGetProcessesEdit 16: Changed _ComputerGetPrinters to include more information and documentation.Edit 17: Added an Example file containing all 11 current UDF's in one simple file.Edit 18: Added _ComputerGetOSs, _ComputerGetShares, _ComputerGetEventLogsEdit 19: Added to the top about no longer requiring a Beta version to work correctly. Requires v3.2 +Edit 20: Added _ComputerGetSoundCards, _ComputerGetVideoCards Updated _ComputerGetGroups (moved "Description" to element 4 to match the rest of the library). Updated Processes, OSs, Processors, Services, Software, Threads, Printers, BIOS, and EventLogs to have the same header layout. Alphabetized CompInfo.au3 and CompInfoExamples.au3Edit 21: Updated _ComputerGetOSs (Bug Fix) in CompInfoExamples.au3 (Thanks Koala)Edit 22: Added _ComputerGetKeyboard, _ComputerGetMouseEdit 23: Added _ComputerGetSystemProduct, _ComputerGetBootConfig Updated Spelling errors and misc items in CompInfoExamples.au3Edit 24: Added _ComputerGetNetworkCardsEdit 25: Added _ComputerGetExtensions, and _ComputerGetSystemEdit 26: Added _ComputerGetDesktops, _ComputerGetDependentServices, _ComputerGetPrintJobs, _ComputerGetBattery, _ComputerGetMotherboard, and _ComputerGetMonitorEdit 27: Added _ComputerGetMemory, and _ComputerGetLoggedOnUsersEdit 28: Updated CompInfo Version Information ErrorEdit 29: Linked ?do=embed' frameborder='0' data-embedContent>Thanks,JS Edited November 26, 2010 by JSThePatriot RestrictedUser, faldo, coffeeturtle and 1 other 3 1 AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Reaper HGN Posted July 19, 2006 Posted July 19, 2006 I like this idea alot. It seems like you could have quite a few additional components. What about: _ComputerGetGroups _ComputerGetEventLog _ComputerGetMem _ComuterGetCPU Those are just a few that I have seen from others. -Great start though.
JSThePatriot Posted July 19, 2006 Author Posted July 19, 2006 (edited) I like this idea alot. It seems like you could have quite a few additional components. What about:_ComputerGetGroups_ComputerGetEventLog_ComputerGetMem_ComuterGetCPUThose are just a few that I have seen from others.-Great start though. Thank you for the ideas... The _ComputerGetMem is already done in MemGetStats(). I could however make a wrapper that returned MB's or GB's based on size and what not.Again thanks for the additional ideas. I will add them shortly.Edit: Spelling.JS Edited July 19, 2006 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
JSThePatriot Posted July 19, 2006 Author Posted July 19, 2006 Check first post, but I added _ComputerGetPrinters. Will be working on more additions shortly. I recieved the CPU info for a single processor, in my compInfo.au3 script that I made these UDF's for, but I am going to standardize it and allow for multiple processors. (I have one at home ). I am working to standardize, and add headers to the UDF's for submission to the Standard UDF Library. Thanks for your continued support. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
JSThePatriot Posted July 19, 2006 Author Posted July 19, 2006 Added _ComputerGetCPUs. I am unable to test _ComputerGetCPUs on a multi processor machine until I am able to get home. If someone can test to be sure that this works on multi processor machine I would be much obliged, I will let you know when I can test it on my home machine (must have virii removed first...roomates). Should _DriveGetInfo be renamed to _ComputerGetDrives? I think that would line up more on the _ComputerGet*Info* standardization that I have been following. Thanks, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Reaper HGN Posted July 19, 2006 Posted July 19, 2006 Added _ComputerGetCPUs. I am unable to test _ComputerGetCPUs on a multi processor machine until I am able to get home. If someone can test to be sure that this works on multi processor machine I would be much obliged, I will let you know when I can test it on my home machine (must have virii removed first...roomates).Should _DriveGetInfo be renamed to _ComputerGetDrives? I think that would line up more on the _ComputerGet*Info* standardization that I have been following.Thanks,JSI would say yes to the standard naming. Ill see if I can test it on a multi cpu system. I wonder how it works with a hyperthreaded cpu?
JSThePatriot Posted July 19, 2006 Author Posted July 19, 2006 I would say yes to the standard naming. Ill see if I can test it on a multi cpu system. I wonder how it works with a hyperthreaded cpu? I wouldnt know, but certainly let me know if you have one that it could be tested on. My test.au3 file.Dim $CPUs _ComputerGetCPUs($CPUs) For $i = 1 To $CPUs[0][0] Step 1 MsgBox(0, "Test $CPUs[$i][1-4]", "Speed: " & $CPUs[$i][1] & @CRLF & "Name: " & $CPUs[$i][2] & @CRLF & "ID: " & $CPUs[$i][3] & @CRLF & "VendorID: " & $CPUs[$i][4] & @CRLF & "Architecture: " & $CPUs[$i][5]) Next Func _ComputerGetCPUs(ByRef $aCPUInfo) Local $HKLMCentralProc = "HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor" Local $CentralProcKey Dim $aCPUInfo[1][6], $i = 1 While 1 $CentralProcKey = RegEnumKey($HKLMCentralProc, $i) If @error <> 0 Then ExitLoop ReDim $aCPUInfo[UBound($aCPUInfo) + 1][6] $aCPUInfo[$i][1] = RegRead($HKLMCentralProc & "\" & $CentralProcKey, "~MHz") / 1000 $aCPUInfo[$i][2] = StringStripWS(RegRead($HKLMCentralProc & "\" & $CentralProcKey, "ProcessorNameString"), 1) $aCPUInfo[$i][3] = RegRead($HKLMCentralProc & "\" & $CentralProcKey, "Identifier") $aCPUInfo[$i][4] = RegRead($HKLMCentralProc & "\" & $CentralProcKey, "VendorIdentifier") $aCPUInfo[$i][5] = @ProcessorArch $i += 1 WEnd $aCPUInfo[0][0] = UBound($aCPUInfo, 1) - 1 EndFunc I hope that helps you in your testing. It is faster than typing it out yourself. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
JSThePatriot Posted July 19, 2006 Author Posted July 19, 2006 Would anyone be interested in a _ComputerGetMem and/or _ComputerGetProcesses? The reason I ask is they are already returned in a full and complete array by MemGetStats, and ProcessList respectively. Please give me your opinions on it. @Reaper HGN I am unsure how I should go about coding the _ComputerGetEventLog. I dont know where the data is stored. :-/ I have looked on MSDN, and they have C++ examples of how to get the EventLog information, but I am unable to find many more resources on how to obtain that information. I may be looking in the wrong places or searching with the wrong terms. Any pointers in the right direction would be greatly appreciated. Thanks, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
JSThePatriot Posted July 19, 2006 Author Posted July 19, 2006 I added a header and error checkin to _ComputerGetDrives. Please let me know if this is too much in your opinion and why, or if there is a better way to do that. Thanks, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Reaper HGN Posted July 19, 2006 Posted July 19, 2006 @JSThePatriot, do you have a zip with the library and any changes you have made?
Reaper HGN Posted July 19, 2006 Posted July 19, 2006 I took your test code and ran it on a system with 2 HT cpus. I get the image you see below. Note that the processor info message box comes up 4 times (once for each processor). The HT processors count as two processors.
JSThePatriot Posted July 19, 2006 Author Posted July 19, 2006 I took your test code and ran it on a system with 2 HT cpus. I get the image you see below. Note that the processor info message box comes up 4 times (once for each processor). The HT processors count as two processors.Awesome glad to know it's working. I need to add some error checking for processors that are under GHz range.Thank you very much for that information.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
JSThePatriot Posted July 19, 2006 Author Posted July 19, 2006 @JSThePatriot, do you have a zip with the library and any changes you have made? I actually have all the changes reflected in the first post, and my only file is a single compInfo.au3 file that I have been using to collect data at work and for realtime testing. compInfo.au3 Please note that I wont be updating this attachment. All updates will be reflected in the first post for ease. I may include this script in the top post once I have it completely done. Thanks, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Reaper HGN Posted July 19, 2006 Posted July 19, 2006 Would anyone be interested in a _ComputerGetMem and/or _ComputerGetProcesses?The reason I ask is they are already returned in a full and complete array by MemGetStats, and ProcessList respectively.Please give me your opinions on it.@Reaper HGNI am unsure how I should go about coding the _ComputerGetEventLog. I dont know where the data is stored. :-/I have looked on MSDN, and they have C++ examples of how to get the EventLog information, but I am unable to find many more resources on how to obtain that information. I may be looking in the wrong places or searching with the wrong terms.Any pointers in the right direction would be greatly appreciated.Thanks,JSI have looked around and didnt find anything difinitive. However, I did find some reference to a method in advapi32 called GetEventLogInformation. There is also an eventlog.dll that may have something in it. Using dllcall, we may be able to piggyback on one of those DLLs.
JSThePatriot Posted July 20, 2006 Author Posted July 20, 2006 I have looked around and didnt find anything difinitive. However, I did find some reference to a method in advapi32 called GetEventLogInformation. There is also an eventlog.dll that may have something in it. Using dllcall, we may be able to piggyback on one of those DLLs.Before I piggy on a DLL I think I would write a plugin since msdn does have the needed C++ code for it all, and then I would know which functions are available and what not.I would prefer at this time for these UDF's to be completely based on AutoIt. Maybe a plugin in the future would be a great addition to be able to do all the tasks at a possible "faster" rate of speed due to the plugin architecture.Thanks for the info.What do you think about the _ComputerGetMem and _ComputerGetProcessesThanks again for everything,JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Reaper HGN Posted July 20, 2006 Posted July 20, 2006 Before I piggy on a DLL I think I would write a plugin since msdn does have the needed C++ code for it all, and then I would know which functions are available and what not.I would prefer at this time for these UDF's to be completely based on AutoIt. Maybe a plugin in the future would be a great addition to be able to do all the tasks at a possible "faster" rate of speed due to the plugin architecture.Thanks for the info.What do you think about the _ComputerGetMem and _ComputerGetProcessesThanks again for everything,JSI understand the "all AutoIT" thing. I personally dont know how to program plugins, so sticking with native AutoIT seems entirely reasonable. I havent messed with the other functions yet. Ill give that a try and let you know.
JSThePatriot Posted July 20, 2006 Author Posted July 20, 2006 I understand the "all AutoIT" thing. I personally dont know how to program plugins, so sticking with native AutoIT seems entirely reasonable. I havent messed with the other functions yet. Ill give that a try and let you know.I appreciate your on going support. I have created a plugin in the past, and am working on adding to it at the moment so creating another wouldnt be too hard.Again I appreciate it all.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Skrip Posted July 21, 2006 Posted July 21, 2006 I can't get the first UDF to work, can you give me an example? [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]
JSThePatriot Posted July 21, 2006 Author Posted July 21, 2006 Let me know if the below helps at all. expandcollapse popupDim $Drives _ComputerGetDrives($Drives) ;Defaults to "FIXED" If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg("DriveGetDrive Error!") Case 2 _ErrorMsg("DriveGetFileSystem Error!") Case 3 _ErrorMsg("DriveGetLabel Error!") Case 4 _ErrorMsg("DriveGetSerial Error!") Case 5 _ErrorMsg("DriveSpaceFree Error!") Case 6 _ErrorMsg("DriveSpaceTotal Error!") EndSwitch EndIf For $i = 1 To $Drives[0][0] Step 1 MsgBox(0, "Drive: " & $Drives[$i][0], "FileSystem: " & $Drives[$i][1] & @CRLF & "Label: " & $Drives[$i][2] & @CRLF & "Serial #: " & $Drives[$i][3] & @CRLF & "Free Space: " & Round($Drives[$i][4] / 1024, 2) & "GB" & @CRLF & "Total Space: " & Round($Drives[$i][5] / 1024, 2) & "GB") Next Func _ErrorMsg($message, $time = 0) MsgBox(48 + 262144, "Error!", $message, $time) EndFunc ;=============================================================================== ; Description: Returns the drive information based on $sDriveType in a two ; dimensional array. First dimension is the index for each set ; of drive information. ; Parameter(s): $aDriveInfo - By Ref - Drive information in an array. ; $sDriveType - Type of drive to return the information on. ; Options: "ALL", "CDROM", "REMOVABLE", "FIXED", ; "NETWORK", "RAMDISK", or "UNKNOWN" ; Defaults to "FIXED" drives. ; Requirement(s): None ; Return Value(s): On Success - Returns array of drive information. ; $aDriveInfo[0][0] = Number of Drives ; The second dimension is as follows: ($i starts at 1) ; [$i][0] - Drive Letter (ex. C:\) ; [$i][1] - File System ; [$i][2] - Label ; [$i][3] - Serial Number ; [$i][4] - Free Space ; [$i][5] - Total Space ; On Failure - Return 0 - SetError - 1 ; SetExtended: 1 = DriveGetDrive Error ; 2 = DriveGetFileSystem Error ; 3 = DriveGetLabel Error ; 4 = DriveGetSerial Error ; 5 = DriveSpaceFree Error ; 6 = DriveSpaceTotal Error ; Author(s): Jarvis Stubblefield (support "at" vortexrevolutions "dot" com) ; Note(s): ; ;=============================================================================== Func _ComputerGetDrives(ByRef $aDriveInfo, $sDriveType = "FIXED") Local $drive $drive = DriveGetDrive($sDriveType) If NOT @error Then Dim $aDriveInfo[UBound($drive)][6] $aDriveInfo[0][0] = $drive[0] For $i = 1 To $aDriveInfo[0][0] Step 1 $aDriveInfo[$i][0] = StringUpper($drive[$i] & "\") $aDriveInfo[$i][1] = DriveGetFileSystem($drive[$i]) If @error Then SetError(1, 2, 0) $aDriveInfo[$i][2] = DriveGetLabel($drive[$i]) If @error Then SetError(1, 3, 0) $aDriveInfo[$i][3] = DriveGetSerial($drive[$i]) If @error Then SetError(1, 4, 0) $aDriveInfo[$i][4] = DriveSpaceFree($drive[$i]) If @error Then SetError(1, 5, 0) $aDriveInfo[$i][5] = DriveSpaceTotal($drive[$i]) If @error Then SetError(1, 6, 0) Next Else SetError(1, 1, 0) EndIf EndFunc I hope the above helps you to be able to use my UDF's. I do appreciate your post and will assist you in any way I can. Thanks again, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Skrip Posted July 21, 2006 Posted July 21, 2006 (edited) Works great, and can I incorporate these UDF's into my computer details program? V3 is still under construction. got this on _computergetusers() C:\AutoIt3\comp_UDF_TEST.au3 (96) : ==> Variable used without being declared.: Local $objDomain = ObjGet("WinNT://" & $cI_Compname & "" ) Local $objDomain = ObjGet("WinNT://" & ^ ERROR _ComputerGetUsers($Usernames) For $i = 1 To $Usernames[0][0] Step 1 MsgBox(0, "Drive: " & $Usernames[$i][0], "FileSystem: " & $Usernames[$i][1] & @CRLF & "Label: " & $Usernames[$i][2] & @CRLF & "Serial #: " & $Usernames[$i][3] & @CRLF & "Free Space: " & Round($Usernames[$i][4] / 1024, 2) & "GB" & @CRLF & "Total Space: " & Round($Usernames[$i][5] / 1024, 2) & "GB") Next Func _ComputerGetUsers(ByRef $Usernames) Dim $Usernames[1] Local $i = 1 $oMyError = ObjEvent("AutoIt.Error", "ComError") Local $objDomain = ObjGet("WinNT://" & $cI_Compname & "" ) Dim $filter[2] = ["user"] $objDomain.Filter = $filter For $aUser In $objDomain ReDim $Usernames[UBound($Usernames) + 1] $Usernames[$i] = $aUSer.Name $i += 1 Next $Usernames[0] = UBound($Usernames) - 1 EndFunc Should that work? (Yes i am using beta) Edited July 21, 2006 by Firestorm [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]
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