Fukima Posted January 29, 2015 Share Posted January 29, 2015 Greetings, I have come to a bit of a problem. I am trying to get information from a computer and print into a text file. I have one function that I found in the forum and I have tried to customize to my needs but unfortunately I must been missing something because I can't it to work. Here is the function I am working on: #include "CompInfo.au3" ;If you are wanting to pull WMI data from different computers then Declare $cI_CompName as the computer name before the include. #region Header #comments-start Title: Computer Information Automation UDF Library for AutoIt3 - EXAMPLES Filename: CompInfoExamples.au3 Description: Examples using the UDF's from CompInfo.au3 Author: Jarvis J. Stubblefield (JSThePatriot) http://www.vortexrevolutions.com/ Version: 00.03.08 Last Update: 11.09.06 Requirements: AutoIt v3.2 +, Developed/Tested on WindowsXP Pro Service Pack 2 Notes: Errors associated with incorrect objects will be common user errors. AutoIt beta 3.1.1.63 has added an ObjName() function that will be used to trap and report most of these errors. Special thanks to Firestorm (Testing, Use), Koala (Testing, Bug Fix), and everyone else that has helped in the creation of this Example File. #comments-end #endregion Header Local $FileNamePC = "c:test.txt" Global $PcInfo = Fileopen($FileNamePC, 10) ; Check if file opened for writing OK If $PcInfo = -1 Then MsgBox(0, "Error", "Unable to open file the logfile MP510.") Exit EndIf local $axul #region ---- Software Functions while 1>1 #region -- Users Dim $Users _ComputerGetUsers($Users) For $i = 1 To $Users[0][0] Step 1 FileWriteLine($FileNamePC, "Name: " & $Users[$i][0] & @CRLF & _ "Domain: " & $Users[$i][1] & @CRLF & _ "Status: " & $Users[$i][2] & @CRLF & _ "Local Account: " & $Users[$i][3] & @CRLF & _ "SID: " & $Users[$i][4] & @CRLF & _ "SIDType: " & $Users[$i][5] & @CRLF & _ "Description: " & $Users[$i][6] & @CRLF & _ "Full Name: " & $Users[$i][7] & @CRLF & _ "Disabled: " & $Users[$i][8] & @CRLF & _ "Lockout: " & $Users[$i][9] & @CRLF & _ "Password Changeable: " & $Users[$i][10] & @CRLF & _ "Password Expires: " & $Users[$i][11] & @CRLF & _ "Password Required: " & $Users[$i][12] & @CRLF & _ "Account Type: " & $Users[$i][13]) Next #endregion Users #endregion Software Functions wend FileClose($FileNamePC) #region ---- Internal Functions Func _ErrorMsg($message, $time = 0) MsgBox(48 + 262144, "Error!", $message, $time) EndFunc #endregion Internal Functions Any help is greatly appreciated Thank you very much. [spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler] Never compromise even in the face of Armageddon [/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler] Link to comment Share on other sites More sharing options...
kylomas Posted January 29, 2015 Share Posted January 29, 2015 (edited) Rorschach, The code fragment you posted is from 2006 and is not runnable. Search for a script called "scriptomatic" for the kinds of info that you are looking for. As far as writing to a file see the Help file for "FileWrite" (and other File* functions). Come up with some runnable code if you need more help. Also, the easier you make it to help you the more help you will get (hint, don't bury your code in a spoiler and use code tags - see my sig). kylomas Edited January 29, 2015 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted January 29, 2015 Share Posted January 29, 2015 This will get you started (modified from scriptomatic generated script)... expandcollapse popuplocal $wbemFlagReturnImmediately = 0x10 local $wbemFlagForwardOnly = 0x20 local $str $oWMI = ObjGet("winmgmts:\\.\root\CIMV2") $oItems = $oWMI.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($oItems) then For $oItem In $oItems $str &= "AccountType=" & $oItem.AccountType & @CRLF $str &= "Caption=" & $oItem.Caption & @CRLF $str &= "Description=" & $oItem.Description & @CRLF $str &= "Disabled=" & $oItem.Disabled & @CRLF $str &= "Domain=" & $oItem.Domain & @CRLF $str &= "FullName=" & $oItem.FullName & @CRLF $str &= "InstallDate=" & WMIDateStringToDate($oItem.InstallDate) & @CRLF $str &= "LocalAccount=" & $oItem.LocalAccount & @CRLF $str &= "Lockout=" & $oItem.Lockout & @CRLF $str &= "Name=" & $oItem.Name & @CRLF $str &= "PasswordChangeable=" & $oItem.PasswordChangeable & @CRLF $str &= "PasswordExpires=" & $oItem.PasswordExpires & @CRLF $str &= "PasswordRequired=" & $oItem.PasswordRequired & @CRLF $str &= "SID=" & $oItem.SID & @CRLF $str &= "SIDType=" & $oItem.SIDType & @CRLF $str &= "Status=" & $oItem.Status & @CRLF Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_UserAccount" ) Endif ConsoleWrite($str & @CRLF) Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Fukima Posted January 29, 2015 Author Share Posted January 29, 2015 (edited) Kylomas, I apologize if I used the wrong procedures to make a post. But will all due respect the script works I am just having problems writing in a text file. I have tried using filewrite and filewriteline both didn't work. expandcollapse popup#include "CompInfo.au3" ;If you are wanting to pull WMI data from different computers then Declare $cI_CompName as the computer name before the include. #region Header #comments-start Title: Computer Information Automation UDF Library for AutoIt3 - EXAMPLES Filename: CompInfoExamples.au3 Description: Examples using the UDF's from CompInfo.au3 Author: Jarvis J. Stubblefield (JSThePatriot) http://www.vortexrevolutions.com/ Version: 00.03.08 Last Update: 11.09.06 Requirements: AutoIt v3.2 +, Developed/Tested on WindowsXP Pro Service Pack 2 Notes: Errors associated with incorrect objects will be common user errors. AutoIt beta 3.1.1.63 has added an ObjName() function that will be used to trap and report most of these errors. Special thanks to Firestorm (Testing, Use), Koala (Testing, Bug Fix), and everyone else that has helped in the creation of this Example File. #comments-end #endregion Header Local $FileNamePC = "c:\test.txt" Global $PcInfo = Fileopen($FileNamePC, 10) ; Check if file opened for writing OK If $PcInfo = -1 Then MsgBox(0, "Error", "Unable to open file the logfile MP510.") Exit EndIf local $axul #region ---- Software Functions while 1>1 #region -- Users Dim $Users _ComputerGetUsers($Users) For $i = 1 To $Users[0][0] Step 1 FileWrite($FileNamePC, "Name: " & $Users[$i][0] & @CRLF & _ "Domain: " & $Users[$i][1] & @CRLF & _ "Status: " & $Users[$i][2] & @CRLF & _ "Local Account: " & $Users[$i][3] & @CRLF & _ "SID: " & $Users[$i][4] & @CRLF & _ "SIDType: " & $Users[$i][5] & @CRLF & _ "Description: " & $Users[$i][6] & @CRLF & _ "Full Name: " & $Users[$i][7] & @CRLF & _ "Disabled: " & $Users[$i][8] & @CRLF & _ "Lockout: " & $Users[$i][9] & @CRLF & _ "Password Changeable: " & $Users[$i][10] & @CRLF & _ "Password Expires: " & $Users[$i][11] & @CRLF & _ "Password Required: " & $Users[$i][12] & @CRLF & _ "Account Type: " & $Users[$i][13]) Next #endregion Users #endregion Software Functions wend #region -- BIOS Dim $BIOS _ComputerGetBIOS($BIOS) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg($ERR_NO_INFO) Case 2 _ErrorMsg($ERR_NOT_OBJ) EndSwitch EndIf For $i = 1 To $BIOS[0][0] Step 1 MsgBox(0, "Test _ComputerGetBIOS", "Name: " & $BIOS[$i][0] & @CRLF & _ "Status: " & $BIOS[$i][1] & @CRLF & _ "BIOS Characteristics: " & $BIOS[$i][2] & @CRLF & _ "BIOS Version: " & $BIOS[$i][3] & @CRLF & _ "Description: " & $BIOS[$i][4] & @CRLF & _ "Build Number: " & $BIOS[$i][5] & @CRLF & _ "Code Set: " & $BIOS[$i][6] & @CRLF & _ "Current Language: " & $BIOS[$i][7] & @CRLF & _ "Identification Code: " & $BIOS[$i][8] & @CRLF & _ "Installable Languages: " & $BIOS[$i][9] & @CRLF & _ "Language Edition: " & $BIOS[$i][10] & @CRLF & _ "List of Languages: " & $BIOS[$i][11] & @CRLF & _ "Manufacturer: " & $BIOS[$i][12] & @CRLF & _ "Other Target OS: " & $BIOS[$i][13] & @CRLF & _ "Primary BIOS: " & $BIOS[$i][14] & @CRLF & _ "Release Date: " & $BIOS[$i][15] & @CRLF & _ "Serial Number: " & $BIOS[$i][16] & @CRLF & _ "SM BIOS BIOS Version: " & $BIOS[$i][17] & @CRLF & _ "SM BIOS Major Version: " & $BIOS[$i][18] & @CRLF & _ "SM BIOS Minor Version: " & $BIOS[$i][19] & @CRLF & _ "SM BIOS Present: " & $BIOS[$i][20] & @CRLF & _ "Software Element ID: " & $BIOS[$i][21] & @CRLF & _ "Software Element State: " & $BIOS[$i][22] & @CRLF & _ "Target Operating System: " & $BIOS[$i][23] & @CRLF & _ "Version: " & $BIOS[$i][24]) Next #endregion BIOS #region -- Memory Dim $Memory ;_ComputerGetMemory($Memory) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg($ERR_NO_INFO) Case 2 _ErrorMsg($ERR_NOT_OBJ) EndSwitch EndIf For $i = 1 To $Memory[0][0] Step 1 MsgBox(0, "Test _ComputerGetMemory", "Name: " & $Memory[$i][0] & @CRLF & _ "BankLabel: " & $Memory[$i][1] & @CRLF & _ "Capacity: " & $Memory[$i][2] & @CRLF & _ "CreationClassName: " & $Memory[$i][3] & @CRLF & _ "Description: " & $Memory[$i][4] & @CRLF & _ "DataWidth: " & $Memory[$i][5] & @CRLF & _ "DeviceLocator: " & $Memory[$i][6] & @CRLF & _ "FormFactor: " & $Memory[$i][7] & @CRLF & _ "HotSwappable: " & $Memory[$i][8] & @CRLF & _ "InterleaveDataDepth: " & $Memory[$i][9] & @CRLF & _ "InterleavePosition: " & $Memory[$i][10] & @CRLF & _ "Manufacturer: " & $Memory[$i][11] & @CRLF & _ "MemoryType: " & $Memory[$i][12] & @CRLF & _ "Model: " & $Memory[$i][13] & @CRLF & _ "OtherIdentifyingInfo: " & $Memory[$i][14] & @CRLF & _ "PartNumber: " & $Memory[$i][15] & @CRLF & _ "PositionInRow: " & $Memory[$i][16] & @CRLF & _ "PoweredOn: " & $Memory[$i][17] & @CRLF & _ "Removable: " & $Memory[$i][18] & @CRLF & _ "Replaceable: " & $Memory[$i][19] & @CRLF & _ "SerialNumber: " & $Memory[$i][20] & @CRLF & _ "SKU: " & $Memory[$i][21] & @CRLF & _ "Speed: " & $Memory[$i][22] & @CRLF & _ "Status: " & $Memory[$i][23] & @CRLF & _ "Tag: " & $Memory[$i][24] & @CRLF & _ "TotalWidth: " & $Memory[$i][25] & @CRLF & _ "TypeDetail: " & $Memory[$i][26] & @CRLF & _ "Version: " & $Memory[$i][27]) Next #endregion Memory #region -- Motherboard Dim $Motherboard ;_ComputerGetMotherboard($Motherboard) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg($ERR_NO_INFO) Case 2 _ErrorMsg($ERR_NOT_OBJ) EndSwitch EndIf For $i = 1 To $Motherboard[0][0] Step 1 MsgBox(0, "Test _ComputerGetMotherboard", "Name: " & $Motherboard[$i][0] & @CRLF & _ "Availability: " & $Motherboard[$i][1] & @CRLF & _ "ConfigManagerErrorCode: " & $Motherboard[$i][2] & @CRLF & _ "ConfigManagerUserConfig: " & $Motherboard[$i][3] & @CRLF & _ "Description: " & $Motherboard[$i][4] & @CRLF & _ "CreationClassName: " & $Motherboard[$i][5] & @CRLF & _ "DeviceID: " & $Motherboard[$i][6] & @CRLF & _ "ErrorCleared: " & $Motherboard[$i][7] & @CRLF & _ "ErrorDescription: " & $Motherboard[$i][8] & @CRLF & _ "LastErrorCode: " & $Motherboard[$i][9] & @CRLF & _ "PNPDeviceID: " & $Motherboard[$i][10] & @CRLF & _ "PowerManagementCapabilities: " & $Motherboard[$i][11] & @CRLF & _ "PowerManagementSupported: " & $Motherboard[$i][12] & @CRLF & _ "PrimaryBusType: " & $Motherboard[$i][13] & @CRLF & _ "RevisionNumber: " & $Motherboard[$i][14] & @CRLF & _ "SecondaryBusType: " & $Motherboard[$i][15] & @CRLF & _ "Status: " & $Motherboard[$i][16] & @CRLF & _ "StatusInfo: " & $Motherboard[$i][17] & @CRLF & _ "SystemCreationClassName: " & $Motherboard[$i][18] & @CRLF & _ "SystemName: " & $Motherboard[$i][19]) Next #endregion Motherboard #region -- Network Cards Dim $NetworkCards ;_ComputerGetNetworkCards($NetworkCards) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg($ERR_NO_INFO) Case 2 _ErrorMsg($ERR_NOT_OBJ) EndSwitch EndIf For $i = 1 To $NetworkCards[0][0] Step 1 MsgBox(0, "Test _ComputerGetNetworkCards", "Name: " & $NetworkCards[$i][0] & @CRLF & _ "Adapter Type: " & $NetworkCards[$i][1] & @CRLF & _ "Adapter Type ID: " & $NetworkCards[$i][2] & @CRLF & _ "Auto Sense: " & $NetworkCards[$i][3] & @CRLF & _ "Description: " & $NetworkCards[$i][4] & @CRLF & _ "Availability: " & $NetworkCards[$i][5] & @CRLF & _ "Config Manager Error Code: " & $NetworkCards[$i][6] & @CRLF & _ "Config Manager User Config: " & $NetworkCards[$i][7] & @CRLF & _ "Creation Class Name: " & $NetworkCards[$i][8] & @CRLF & _ "Device ID: " & $NetworkCards[$i][9] & @CRLF & _ "Error Cleared: " & $NetworkCards[$i][10] & @CRLF & _ "Error Description: " & $NetworkCards[$i][11] & @CRLF & _ "Index: " & $NetworkCards[$i][12] & @CRLF & _ "Installed: " & $NetworkCards[$i][13] & @CRLF & _ "Last Error Code: " & $NetworkCards[$i][14] & @CRLF & _ "MAC Address: " & $NetworkCards[$i][15] & @CRLF & _ "Manufacturer: " & $NetworkCards[$i][16] & @CRLF & _ "Max Number Controlled: " & $NetworkCards[$i][17] & @CRLF & _ "Max Speed: " & $NetworkCards[$i][18] & @CRLF & _ "Net Connection ID: " & $NetworkCards[$i][19] & @CRLF & _ "Net Connection Status: " & $NetworkCards[$i][20] & @CRLF & _ "Network Addresses: " & $NetworkCards[$i][21] & @CRLF & _ "Permanent Address: " & $NetworkCards[$i][22] & @CRLF & _ "PNP Device ID: " & $NetworkCards[$i][23] & @CRLF & _ "Power Management Capabilities: " & $NetworkCards[$i][24] & @CRLF & _ "Power Management Supported: " & $NetworkCards[$i][25] & @CRLF & _ "Product Name: " & $NetworkCards[$i][26] & @CRLF & _ "Service Name: " & $NetworkCards[$i][27] & @CRLF & _ "Speed: " & $NetworkCards[$i][28] & @CRLF & _ "Status: " & $NetworkCards[$i][29] & @CRLF & _ "Status Info: " & $NetworkCards[$i][30] & @CRLF & _ "System Creation Class Name: " & $NetworkCards[$i][31] & @CRLF & _ "System Name: " & $NetworkCards[$i][32] & @CRLF & _ "Time Of Last Reset: " & $NetworkCards[$i][33]) Next #endregion #region -- Processors Dim $Processors ;_ComputerGetProcessors($Processors) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg($ERR_NO_INFO) Case 2 _ErrorMsg($ERR_NOT_OBJ) EndSwitch EndIf For $i = 1 To $Processors[0][0] Step 1 MsgBox(0, "Test _ComputerGetProcessors", "Name: " & $Processors[$i][0] & @CRLF & _ "Address Width: " & $Processors[$i][1] & @CRLF & _ "Architecture: " & $Processors[$i][2] & @CRLF & _ "Availability: " & $Processors[$i][3] & @CRLF & _ "Description: " & $Processors[$i][4] & @CRLF & _ "Config Manager Error Code: " & $Processors[$i][5] & @CRLF & _ "Config Manager User Config: " & $Processors[$i][6] & @CRLF & _ "CPU Status: " & $Processors[$i][7] & @CRLF & _ "Creation Class Name: " & $Processors[$i][8] & @CRLF & _ "Current Clock Speed: " & $Processors[$i][9] & @CRLF & _ "Current Voltage: " & $Processors[$i][10] & @CRLF & _ "Data Width: " & $Processors[$i][11] & @CRLF & _ "Device ID: " & $Processors[$i][12] & @CRLF & _ "Error Cleared: " & $Processors[$i][13] & @CRLF & _ "Error Description: " & $Processors[$i][14] & @CRLF & _ "Ext Clock: " & $Processors[$i][15] & @CRLF & _ "Family: " & $Processors[$i][16] & @CRLF & _ "L2 Cache Size: " & $Processors[$i][17] & @CRLF & _ "L2 Cache Speed: " & $Processors[$i][18] & @CRLF & _ "Last Error Code: " & $Processors[$i][19] & @CRLF & _ "Level: " & $Processors[$i][20] & @CRLF & _ "Load Percentage: " & $Processors[$i][21] & @CRLF & _ "Manufacturer: " & $Processors[$i][22] & @CRLF & _ "Max Clock Speed: " & $Processors[$i][23] & @CRLF & _ "Other Family Description: " & $Processors[$i][24] & @CRLF & _ "PNP Device ID: " & $Processors[$i][25] & @CRLF & _ "Power Management Capabilities: " & $Processors[$i][26] & @CRLF & _ "Power Management Supported: " & $Processors[$i][27] & @CRLF & _ "Processor ID: " & $Processors[$i][28] & @CRLF & _ "Processor Type: " & $Processors[$i][29] & @CRLF & _ "Revision: " & $Processors[$i][30] & @CRLF & _ "Role: " & $Processors[$i][31] & @CRLF & _ "Socket Designation: " & $Processors[$i][32] & @CRLF & _ "Status: " & $Processors[$i][33] & @CRLF & _ "Status Info: " & $Processors[$i][34] & @CRLF & _ "Stepping: " & $Processors[$i][35] & @CRLF & _ "System Creation Class Name: " & $Processors[$i][36] & @CRLF & _ "System Name: " & $Processors[$i][37] & @CRLF & _ "Unique ID: " & $Processors[$i][38] & @CRLF & _ "Upgrade Method: " & $Processors[$i][39] & @CRLF & _ "Version: " & $Processors[$i][40] & @CRLF & _ "Voltage Caps: " & $Processors[$i][41]) Next #endregion Processors #region -- System Dim $System ;_ComputerGetSystem($System) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg("Array contains no information.") Case 2 _ErrorMsg("$colItems isnt an object.") EndSwitch EndIf #region -- System Product ;NOTE: UUID will return 0000's if it is unable to create a UUID. Dim $SystemProduct _ComputerGetSystemProduct($SystemProduct) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg($ERR_NO_INFO) Case 2 _ErrorMsg($ERR_NOT_OBJ) EndSwitch EndIf For $i = 1 To $SystemProduct[0][0] Step 1 MsgBox(0, "Test _ComputerGetSystemProduct", "Name: " & $SystemProduct[$i][0] & @CRLF & _ "Identifying Number: " & $SystemProduct[$i][1] & @CRLF & _ "SKU Number: " & $SystemProduct[$i][2] & @CRLF & _ "UUID: " & $SystemProduct[$i][3] & @CRLF & _ "Description: " & $SystemProduct[$i][4] & @CRLF & _ "Vendor: " & $SystemProduct[$i][5] & @CRLF & _ "Version: " & $SystemProduct[$i][6]) Next #endregion System Product #region -- Video Cards Dim $VideoCards ;_ComputerGetVideoCards($VideoCards) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg($ERR_NO_INFO) Case 2 _ErrorMsg($ERR_NOT_OBJ) EndSwitch EndIf ;closes the log file FileClose($FileNamePC) #endregion Hardware Functions #region ---- Internal Functions Func _ErrorMsg($message, $time = 0) MsgBox(48 + 262144, "Error!", $message, $time) EndFunc #endregion Internal Functions That is what I got so far I am just trying to make those message boxes write in text file. thanks, Edited Just saw your new post. I will try it out. thank you, Edited January 29, 2015 by Rorschach [spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler] Never compromise even in the face of Armageddon [/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler] Link to comment Share on other sites More sharing options...
kylomas Posted January 29, 2015 Share Posted January 29, 2015 (edited) Your first post does NOT run. What you posted just now does. In light of your new code what I posted does not make sense for your issue. Give me a moment to look at it. kylomas edit: correction - your second code example does not run on my pc either but it is closer Edited January 29, 2015 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Solution kylomas Posted January 29, 2015 Solution Share Posted January 29, 2015 (edited) Rorschach, Your filewrite is working fine. Your while...wend loop is not running because 1 is never greater than 1. Not sure why the while...wend is even there, better off without it. Regardless, try this, it runs on my pc... expandcollapse popup#include <array.au3> #include "CompInfo.au3" ;If you are wanting to pull WMI data from different computers then Declare $cI_CompName as the computer name before the include. #Region Header #comments-start Title: Computer Information Automation UDF Library for AutoIt3 - EXAMPLES Filename: CompInfoExamples.au3 Description: Examples using the UDF's from CompInfo.au3 Author: Jarvis J. Stubblefield (JSThePatriot) http://www.vortexrevolutions.com/ Version: 00.03.08 Last Update: 11.09.06 Requirements: AutoIt v3.2 +, Developed/Tested on WindowsXP Pro Service Pack 2 Notes: Errors associated with incorrect objects will be common user errors. AutoIt beta 3.1.1.63 has added an ObjName() function that will be used to trap and report most of these errors. Special thanks to Firestorm (Testing, Use), Koala (Testing, Bug Fix), and everyone else that has helped in the creation of this Example File. #comments-end #EndRegion Header Local $FileNamePC = "c:\test.txt" Global $PcInfo = FileOpen($FileNamePC, 10) ; Check if file opened for writing OK If $PcInfo = -1 Then MsgBox(0, "Error", "Unable to open file the logfile MP510.") Exit EndIf Local $axul #Region ---- Software Functions ;While 1>1 ; the loop will not run because 1 is never greater than 1 While 1 #Region -- Users Dim $Users[1][1] _ComputerGetUsers($Users) if @error then exit ;_arraydisplay($Users) ; for debugging, comment out if not needed For $i = 1 To $Users[0][0] Step 1 FileWrite($FileNamePC, "Name: " & $Users[$i][0] & @CRLF & _ "Domain: " & $Users[$i][1] & @CRLF & _ "Status: " & $Users[$i][2] & @CRLF & _ "Local Account: " & $Users[$i][3] & @CRLF & _ "SID: " & $Users[$i][4] & @CRLF & _ "SIDType: " & $Users[$i][5] & @CRLF & _ "Description: " & $Users[$i][6] & @CRLF & _ "Full Name: " & $Users[$i][7] & @CRLF & _ "Disabled: " & $Users[$i][8] & @CRLF & _ "Lockout: " & $Users[$i][9] & @CRLF & _ "Password Changeable: " & $Users[$i][10] & @CRLF & _ "Password Expires: " & $Users[$i][11] & @CRLF & _ "Password Required: " & $Users[$i][12] & @CRLF & _ "Account Type: " & $Users[$i][13]) Next exitloop ; not sure why this is a loop, however, this will get you out of the loop or eliminate the while...wend altogether #EndRegion -- Users #EndRegion ---- Software Functions WEnd #Region -- BIOS ;~ Dim $BIOS ;~ _ComputerGetBIOS($BIOS) ;~ If @error Then ;~ $error = @error ;~ $extended = @extended ;~ Switch $extended ;~ Case 1 ;~ _ErrorMsg($ERR_NO_INFO) ;~ Case 2 ;~ _ErrorMsg($ERR_NOT_OBJ) ;~ EndSwitch ;~ EndIf ;~ For $i = 1 To $BIOS[0][0] Step 1 ;~ MsgBox(0, "Test _ComputerGetBIOS", "Name: " & $BIOS[$i][0] & @CRLF & _ ;~ "Status: " & $BIOS[$i][1] & @CRLF & _ ;~ "BIOS Characteristics: " & $BIOS[$i][2] & @CRLF & _ ;~ "BIOS Version: " & $BIOS[$i][3] & @CRLF & _ ;~ "Description: " & $BIOS[$i][4] & @CRLF & _ ;~ "Build Number: " & $BIOS[$i][5] & @CRLF & _ ;~ "Code Set: " & $BIOS[$i][6] & @CRLF & _ ;~ "Current Language: " & $BIOS[$i][7] & @CRLF & _ ;~ "Identification Code: " & $BIOS[$i][8] & @CRLF & _ ;~ "Installable Languages: " & $BIOS[$i][9] & @CRLF & _ ;~ "Language Edition: " & $BIOS[$i][10] & @CRLF & _ ;~ "List of Languages: " & $BIOS[$i][11] & @CRLF & _ ;~ "Manufacturer: " & $BIOS[$i][12] & @CRLF & _ ;~ "Other Target OS: " & $BIOS[$i][13] & @CRLF & _ ;~ "Primary BIOS: " & $BIOS[$i][14] & @CRLF & _ ;~ "Release Date: " & $BIOS[$i][15] & @CRLF & _ ;~ "Serial Number: " & $BIOS[$i][16] & @CRLF & _ ;~ "SM BIOS BIOS Version: " & $BIOS[$i][17] & @CRLF & _ ;~ "SM BIOS Major Version: " & $BIOS[$i][18] & @CRLF & _ ;~ "SM BIOS Minor Version: " & $BIOS[$i][19] & @CRLF & _ ;~ "SM BIOS Present: " & $BIOS[$i][20] & @CRLF & _ ;~ "Software Element ID: " & $BIOS[$i][21] & @CRLF & _ ;~ "Software Element State: " & $BIOS[$i][22] & @CRLF & _ ;~ "Target Operating System: " & $BIOS[$i][23] & @CRLF & _ ;~ "Version: " & $BIOS[$i][24]) ;~ Next ;~ #EndRegion -- BIOS ;~ #Region -- Memory ;~ Dim $Memory ;~ _ComputerGetMemory($Memory) ;~ If @error Then ;~ $error = @error ;~ $extended = @extended ;~ Switch $extended ;~ Case 1 ;~ _ErrorMsg($ERR_NO_INFO) ;~ Case 2 ;~ _ErrorMsg($ERR_NOT_OBJ) ;~ EndSwitch ;~ EndIf ;~ For $i = 1 To $Memory[0][0] Step 1 ;~ MsgBox(0, "Test _ComputerGetMemory", "Name: " & $Memory[$i][0] & @CRLF & _ ;~ "BankLabel: " & $Memory[$i][1] & @CRLF & _ ;~ "Capacity: " & $Memory[$i][2] & @CRLF & _ ;~ "CreationClassName: " & $Memory[$i][3] & @CRLF & _ ;~ "Description: " & $Memory[$i][4] & @CRLF & _ ;~ "DataWidth: " & $Memory[$i][5] & @CRLF & _ ;~ "DeviceLocator: " & $Memory[$i][6] & @CRLF & _ ;~ "FormFactor: " & $Memory[$i][7] & @CRLF & _ ;~ "HotSwappable: " & $Memory[$i][8] & @CRLF & _ ;~ "InterleaveDataDepth: " & $Memory[$i][9] & @CRLF & _ ;~ "InterleavePosition: " & $Memory[$i][10] & @CRLF & _ ;~ "Manufacturer: " & $Memory[$i][11] & @CRLF & _ ;~ "MemoryType: " & $Memory[$i][12] & @CRLF & _ ;~ "Model: " & $Memory[$i][13] & @CRLF & _ ;~ "OtherIdentifyingInfo: " & $Memory[$i][14] & @CRLF & _ ;~ "PartNumber: " & $Memory[$i][15] & @CRLF & _ ;~ "PositionInRow: " & $Memory[$i][16] & @CRLF & _ ;~ "PoweredOn: " & $Memory[$i][17] & @CRLF & _ ;~ "Removable: " & $Memory[$i][18] & @CRLF & _ ;~ "Replaceable: " & $Memory[$i][19] & @CRLF & _ ;~ "SerialNumber: " & $Memory[$i][20] & @CRLF & _ ;~ "SKU: " & $Memory[$i][21] & @CRLF & _ ;~ "Speed: " & $Memory[$i][22] & @CRLF & _ ;~ "Status: " & $Memory[$i][23] & @CRLF & _ ;~ "Tag: " & $Memory[$i][24] & @CRLF & _ ;~ "TotalWidth: " & $Memory[$i][25] & @CRLF & _ ;~ "TypeDetail: " & $Memory[$i][26] & @CRLF & _ ;~ "Version: " & $Memory[$i][27]) ;~ Next ;~ #EndRegion -- Memory ;~ #Region -- Motherboard ;~ Dim $Motherboard ;~ _ComputerGetMotherboard($Motherboard) ;~ If @error Then ;~ $error = @error ;~ $extended = @extended ;~ Switch $extended ;~ Case 1 ;~ _ErrorMsg($ERR_NO_INFO) ;~ Case 2 ;~ _ErrorMsg($ERR_NOT_OBJ) ;~ EndSwitch ;~ EndIf ;~ For $i = 1 To $Motherboard[0][0] Step 1 ;~ MsgBox(0, "Test _ComputerGetMotherboard", "Name: " & $Motherboard[$i][0] & @CRLF & _ ;~ "Availability: " & $Motherboard[$i][1] & @CRLF & _ ;~ "ConfigManagerErrorCode: " & $Motherboard[$i][2] & @CRLF & _ ;~ "ConfigManagerUserConfig: " & $Motherboard[$i][3] & @CRLF & _ ;~ "Description: " & $Motherboard[$i][4] & @CRLF & _ ;~ "CreationClassName: " & $Motherboard[$i][5] & @CRLF & _ ;~ "DeviceID: " & $Motherboard[$i][6] & @CRLF & _ ;~ "ErrorCleared: " & $Motherboard[$i][7] & @CRLF & _ ;~ "ErrorDescription: " & $Motherboard[$i][8] & @CRLF & _ ;~ "LastErrorCode: " & $Motherboard[$i][9] & @CRLF & _ ;~ "PNPDeviceID: " & $Motherboard[$i][10] & @CRLF & _ ;~ "PowerManagementCapabilities: " & $Motherboard[$i][11] & @CRLF & _ ;~ "PowerManagementSupported: " & $Motherboard[$i][12] & @CRLF & _ ;~ "PrimaryBusType: " & $Motherboard[$i][13] & @CRLF & _ ;~ "RevisionNumber: " & $Motherboard[$i][14] & @CRLF & _ ;~ "SecondaryBusType: " & $Motherboard[$i][15] & @CRLF & _ ;~ "Status: " & $Motherboard[$i][16] & @CRLF & _ ;~ "StatusInfo: " & $Motherboard[$i][17] & @CRLF & _ ;~ "SystemCreationClassName: " & $Motherboard[$i][18] & @CRLF & _ ;~ "SystemName: " & $Motherboard[$i][19]) ;~ Next ;~ #EndRegion -- Motherboard ;~ #Region -- Network Cards ;~ Dim $NetworkCards ;~ _ComputerGetNetworkCards($NetworkCards) ;~ If @error Then ;~ $error = @error ;~ $extended = @extended ;~ Switch $extended ;~ Case 1 ;~ _ErrorMsg($ERR_NO_INFO) ;~ Case 2 ;~ _ErrorMsg($ERR_NOT_OBJ) ;~ EndSwitch ;~ EndIf ;~ For $i = 1 To $NetworkCards[0][0] Step 1 ;~ MsgBox(0, "Test _ComputerGetNetworkCards", "Name: " & $NetworkCards[$i][0] & @CRLF & _ ;~ "Adapter Type: " & $NetworkCards[$i][1] & @CRLF & _ ;~ "Adapter Type ID: " & $NetworkCards[$i][2] & @CRLF & _ ;~ "Auto Sense: " & $NetworkCards[$i][3] & @CRLF & _ ;~ "Description: " & $NetworkCards[$i][4] & @CRLF & _ ;~ "Availability: " & $NetworkCards[$i][5] & @CRLF & _ ;~ "Config Manager Error Code: " & $NetworkCards[$i][6] & @CRLF & _ ;~ "Config Manager User Config: " & $NetworkCards[$i][7] & @CRLF & _ ;~ "Creation Class Name: " & $NetworkCards[$i][8] & @CRLF & _ ;~ "Device ID: " & $NetworkCards[$i][9] & @CRLF & _ ;~ "Error Cleared: " & $NetworkCards[$i][10] & @CRLF & _ ;~ "Error Description: " & $NetworkCards[$i][11] & @CRLF & _ ;~ "Index: " & $NetworkCards[$i][12] & @CRLF & _ ;~ "Installed: " & $NetworkCards[$i][13] & @CRLF & _ ;~ "Last Error Code: " & $NetworkCards[$i][14] & @CRLF & _ ;~ "MAC Address: " & $NetworkCards[$i][15] & @CRLF & _ ;~ "Manufacturer: " & $NetworkCards[$i][16] & @CRLF & _ ;~ "Max Number Controlled: " & $NetworkCards[$i][17] & @CRLF & _ ;~ "Max Speed: " & $NetworkCards[$i][18] & @CRLF & _ ;~ "Net Connection ID: " & $NetworkCards[$i][19] & @CRLF & _ ;~ "Net Connection Status: " & $NetworkCards[$i][20] & @CRLF & _ ;~ "Network Addresses: " & $NetworkCards[$i][21] & @CRLF & _ ;~ "Permanent Address: " & $NetworkCards[$i][22] & @CRLF & _ ;~ "PNP Device ID: " & $NetworkCards[$i][23] & @CRLF & _ ;~ "Power Management Capabilities: " & $NetworkCards[$i][24] & @CRLF & _ ;~ "Power Management Supported: " & $NetworkCards[$i][25] & @CRLF & _ ;~ "Product Name: " & $NetworkCards[$i][26] & @CRLF & _ ;~ "Service Name: " & $NetworkCards[$i][27] & @CRLF & _ ;~ "Speed: " & $NetworkCards[$i][28] & @CRLF & _ ;~ "Status: " & $NetworkCards[$i][29] & @CRLF & _ ;~ "Status Info: " & $NetworkCards[$i][30] & @CRLF & _ ;~ "System Creation Class Name: " & $NetworkCards[$i][31] & @CRLF & _ ;~ "System Name: " & $NetworkCards[$i][32] & @CRLF & _ ;~ "Time Of Last Reset: " & $NetworkCards[$i][33]) ;~ Next ;~ #EndRegion -- Network Cards ;~ #Region -- Processors ;~ Dim $Processors ;~ _ComputerGetProcessors($Processors) ;~ If @error Then ;~ $error = @error ;~ $extended = @extended ;~ Switch $extended ;~ Case 1 ;~ _ErrorMsg($ERR_NO_INFO) ;~ Case 2 ;~ _ErrorMsg($ERR_NOT_OBJ) ;~ EndSwitch ;~ EndIf ;~ For $i = 1 To $Processors[0][0] Step 1 ;~ MsgBox(0, "Test _ComputerGetProcessors", "Name: " & $Processors[$i][0] & @CRLF & _ ;~ "Address Width: " & $Processors[$i][1] & @CRLF & _ ;~ "Architecture: " & $Processors[$i][2] & @CRLF & _ ;~ "Availability: " & $Processors[$i][3] & @CRLF & _ ;~ "Description: " & $Processors[$i][4] & @CRLF & _ ;~ "Config Manager Error Code: " & $Processors[$i][5] & @CRLF & _ ;~ "Config Manager User Config: " & $Processors[$i][6] & @CRLF & _ ;~ "CPU Status: " & $Processors[$i][7] & @CRLF & _ ;~ "Creation Class Name: " & $Processors[$i][8] & @CRLF & _ ;~ "Current Clock Speed: " & $Processors[$i][9] & @CRLF & _ ;~ "Current Voltage: " & $Processors[$i][10] & @CRLF & _ ;~ "Data Width: " & $Processors[$i][11] & @CRLF & _ ;~ "Device ID: " & $Processors[$i][12] & @CRLF & _ ;~ "Error Cleared: " & $Processors[$i][13] & @CRLF & _ ;~ "Error Description: " & $Processors[$i][14] & @CRLF & _ ;~ "Ext Clock: " & $Processors[$i][15] & @CRLF & _ ;~ "Family: " & $Processors[$i][16] & @CRLF & _ ;~ "L2 Cache Size: " & $Processors[$i][17] & @CRLF & _ ;~ "L2 Cache Speed: " & $Processors[$i][18] & @CRLF & _ ;~ "Last Error Code: " & $Processors[$i][19] & @CRLF & _ ;~ "Level: " & $Processors[$i][20] & @CRLF & _ ;~ "Load Percentage: " & $Processors[$i][21] & @CRLF & _ ;~ "Manufacturer: " & $Processors[$i][22] & @CRLF & _ ;~ "Max Clock Speed: " & $Processors[$i][23] & @CRLF & _ ;~ "Other Family Description: " & $Processors[$i][24] & @CRLF & _ ;~ "PNP Device ID: " & $Processors[$i][25] & @CRLF & _ ;~ "Power Management Capabilities: " & $Processors[$i][26] & @CRLF & _ ;~ "Power Management Supported: " & $Processors[$i][27] & @CRLF & _ ;~ "Processor ID: " & $Processors[$i][28] & @CRLF & _ ;~ "Processor Type: " & $Processors[$i][29] & @CRLF & _ ;~ "Revision: " & $Processors[$i][30] & @CRLF & _ ;~ "Role: " & $Processors[$i][31] & @CRLF & _ ;~ "Socket Designation: " & $Processors[$i][32] & @CRLF & _ ;~ "Status: " & $Processors[$i][33] & @CRLF & _ ;~ "Status Info: " & $Processors[$i][34] & @CRLF & _ ;~ "Stepping: " & $Processors[$i][35] & @CRLF & _ ;~ "System Creation Class Name: " & $Processors[$i][36] & @CRLF & _ ;~ "System Name: " & $Processors[$i][37] & @CRLF & _ ;~ "Unique ID: " & $Processors[$i][38] & @CRLF & _ ;~ "Upgrade Method: " & $Processors[$i][39] & @CRLF & _ ;~ "Version: " & $Processors[$i][40] & @CRLF & _ ;~ "Voltage Caps: " & $Processors[$i][41]) ;~ Next ;~ #EndRegion -- Processors ;~ #Region -- System ;~ Dim $System ;~ _ComputerGetSystem($System) ;~ If @error Then ;~ $error = @error ;~ $extended = @extended ;~ Switch $extended ;~ Case 1 ;~ _ErrorMsg("Array contains no information.") ;~ Case 2 ;~ _ErrorMsg("$colItems isnt an object.") ;~ EndSwitch ;~ EndIf ;~ #Region -- System Product ;~ ;NOTE: UUID will return 0000's if it is unable to create a UUID. ;~ Dim $SystemProduct ;~ _ComputerGetSystemProduct($SystemProduct) ;~ If @error Then ;~ $error = @error ;~ $extended = @extended ;~ Switch $extended ;~ Case 1 ;~ _ErrorMsg($ERR_NO_INFO) ;~ Case 2 ;~ _ErrorMsg($ERR_NOT_OBJ) ;~ EndSwitch ;~ EndIf ;~ For $i = 1 To $SystemProduct[0][0] Step 1 ;~ MsgBox(0, "Test _ComputerGetSystemProduct", "Name: " & $SystemProduct[$i][0] & @CRLF & _ ;~ "Identifying Number: " & $SystemProduct[$i][1] & @CRLF & _ ;~ "SKU Number: " & $SystemProduct[$i][2] & @CRLF & _ ;~ "UUID: " & $SystemProduct[$i][3] & @CRLF & _ ;~ "Description: " & $SystemProduct[$i][4] & @CRLF & _ ;~ "Vendor: " & $SystemProduct[$i][5] & @CRLF & _ ;~ "Version: " & $SystemProduct[$i][6]) ;~ Next ;~ #EndRegion -- System Product ;~ #Region -- Video Cards ;~ Dim $VideoCards ;~ _ComputerGetVideoCards($VideoCards) ;~ If @error Then ;~ $error = @error ;~ $extended = @extended ;~ Switch $extended ;~ Case 1 ;~ _ErrorMsg($ERR_NO_INFO) ;~ Case 2 ;~ _ErrorMsg($ERR_NOT_OBJ) ;~ EndSwitch ;~ EndIf ;~ ;closes the log file ;~ FileClose($FileNamePC) ;~ #EndRegion -- Video Cards ;~ #Region ---- Internal Functions ;~ Func _ErrorMsg($message, $time = 0) ;~ MsgBox(48 + 262144, "Error!", $message, $time) ;~ EndFunc ;==>_ErrorMsg ;~ #EndRegion ---- Internal Functions kylomas edit: I explicily declare the 2D array, however this is not neccessary as the UDF redim's whatever var is passed to it. Did this while troubleshooting and forgot to change it back. Edited January 29, 2015 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted January 30, 2015 Share Posted January 30, 2015 Added a @CRLF at the end of you string in filewrite...not in code posted above... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Fukima Posted January 30, 2015 Author Share Posted January 30, 2015 Kylomas, Thank you for your help I will remember that next time. I always have problems with the loop functions. It worked for me as well thanks again, Have a nice evening my friend. [spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler] Never compromise even in the face of Armageddon [/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler] Link to comment Share on other sites More sharing options...
kylomas Posted January 30, 2015 Share Posted January 30, 2015 Please mark your post a "Solved" if your question has been answered. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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