;~ Used resouces from: ; ;~ Title: System Audit Tool ;~ Author: Ian Maxwell (llewxam @ AutoIt forum) ;~ Site: https://www.autoitscript.com/forum/topic/139380-computer-audit-tool/ ; ;~ Title: Local Account ;~ Author: engine (engine @ AutoIt forum) ;~ Site: https://www.autoitscript.com/forum/topic/74118-local-account-udf/ ;~ ;~ Requires LocalAccount.au3 file in the script directory. ;~ ;~ Created by FesterJester @ AutoIt forums ;~ Credit goes to Ian Maxwell (llewxam @ AutoIt forum) for the bulk of the script ;~ and ;~ engine (engine @ AutoIt forum) for the Local Account script. ;~ I just tweaked to my need and made a nice GUI to go with their work. #include #include #include #include #include #include ; https://www.autoitscript.com/forum/topic/74118-local-account-udf/ #include $File = "" $Form1 = GUICreate("Computer Audit Tool", 344, 430, 278, 124) $Text = GUICtrlCreateLabel("Computer Audit Tool", 24, 16, 295, 50, BitOR($SS_CENTERIMAGE,$SS_SUNKEN)) ;GUICtrlSetFont($Text, 23, 800, 4, "Bradley Hand ITC") ;GUICtrlSetFont($Text, 26, 800, 4, "Chiller") GUICtrlSetFont($Text, 22, 800, 4, "Forte") $Select = GUICtrlCreateButton("Select Output File", 24, 90, 140, 25) GUICtrlSetBkColor($Select, 0xEA3F3F) GUICtrlSetColor($Select, 0xFFFFFF) $Execute = GUICtrlCreateButton("Execute", 175, 90, 140, 25) GUICtrlSetState($Execute, $GUI_DISABLE) GUICtrlCreateGroup("Hardware", 24, 136, 137, 97, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER)) $CheckChassis = GUICtrlCreateCheckbox("Chassis", 32, 152, 97, 17) guictrlsetstate($CheckChassis, $GUI_CHECKED) $CheckCPU = GUICtrlCreateCheckbox("CPU", 32, 176, 97, 17) guictrlsetstate($CheckCPU, $GUI_CHECKED) $CheckRAM = GUICtrlCreateCheckbox("RAM", 32, 200, 97, 17) guictrlsetstate($CheckRAM, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Storage", 24, 240, 137, 73, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER)) $CheckLStore = GUICtrlCreateCheckbox("Local Storage", 32, 256, 97, 17) guictrlsetstate($CheckLStore, $GUI_CHECKED) $CheckRStore = GUICtrlCreateCheckbox("Remote Storage", 32, 280, 97, 17) guictrlsetstate($CheckRStore, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Network", 24, 320, 137, 49, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER)) $CheckNet = GUICtrlCreateCheckbox("Network Info", 32, 336, 97, 17) guictrlsetstate($CheckNet, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Users", 176, 136, 137, 49, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER)) $CheckUsers = GUICtrlCreateCheckbox("User Accounts", 184, 152, 97, 17) guictrlsetstate($CheckUsers, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Software", 176, 192, 137, 110, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER)) $CheckOS = GUICtrlCreateCheckbox("Operating System", 184, 208, 113, 17) guictrlsetstate($CheckOS, $GUI_CHECKED) $CheckMSOffice = GUICtrlCreateCheckbox("MS Office", 184, 232, 97, 17) guictrlsetstate($CheckMSOffice, $GUI_CHECKED) $CheckSoftware = GUICtrlCreateCheckbox("Other Software", 184, 256, 97, 17) $SoftwareText = GUICtrlCreateLabel("(May take a while)", 184, 275, 97, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $CheckAll = GUICtrlCreateButton("Select All", 184, 325, 97, 20) $CheckNone = GUICtrlCreateButton("Select None", 184, 349, 97, 20) $Quit = GUICtrlCreateButton("Quit", 24, 380, 295, 40) GUICtrlSetFont($Quit, 22, 400, 0, "Forte") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Quit Exit Case $CheckAll guictrlsetstate($CheckChassis, $GUI_CHECKED) guictrlsetstate($CheckCPU, $GUI_CHECKED) guictrlsetstate($CheckRAM, $GUI_CHECKED) guictrlsetstate($CheckLStore, $GUI_CHECKED) guictrlsetstate($CheckRStore, $GUI_CHECKED) guictrlsetstate($CheckNet, $GUI_CHECKED) guictrlsetstate($CheckUsers, $GUI_CHECKED) guictrlsetstate($CheckOS, $GUI_CHECKED) guictrlsetstate($CheckMSOffice, $GUI_CHECKED) guictrlsetstate($CheckSoftware, $GUI_CHECKED) Case $CheckNone guictrlsetstate($CheckChassis, $GUI_UNCHECKED) guictrlsetstate($CheckCPU, $GUI_UNCHECKED) guictrlsetstate($CheckRAM, $GUI_UNCHECKED) guictrlsetstate($CheckLStore, $GUI_UNCHECKED) guictrlsetstate($CheckRStore, $GUI_UNCHECKED) guictrlsetstate($CheckNet, $GUI_UNCHECKED) guictrlsetstate($CheckUsers, $GUI_UNCHECKED) guictrlsetstate($CheckOS, $GUI_UNCHECKED) guictrlsetstate($CheckMSOffice, $GUI_UNCHECKED) guictrlsetstate($CheckSoftware, $GUI_UNCHECKED) Case $Select $File = FileSaveDialog("Save to file:", ".", "Text (*.csv)", BitOR($FD_PATHMUSTEXIST, $FD_PROMPTOVERWRITE), @ComputerName & "-" & @MON & @MDAY & @YEAR & ".csv") If $File Then GUICtrlSetBkColor($Select, 0xD3D3D3) GUICtrlSetData($Select, "Output File Selected") GUICtrlSetState($Execute, $GUI_ENABLE) GUICtrlSetBkColor($Execute, $COLOR_GREEN) GUICtrlSetColor($Execute, 0xFFFFFF) EndIf Case $Execute GUICtrlSetData($Execute, "Processing...") GUICtrlSetState($Execute, $GUI_DISABLE) GUICtrlSetState($Select, $GUI_DISABLE) $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2") _ProcessCheckBoxes() EndSwitch WEnd Func _ProcessCheckBoxes() _CreateFile() If GuiCtrlRead($CheckChassis) = 1 Then _Hardware() EndIf If GuiCtrlRead($CheckCPU) = 1 Then _CPU() EndIf If GuiCtrlRead($CheckRAM) = 1 Then _RAM() EndIf If GuiCtrlRead($CheckLStore) = 1 Then _LocalStorage() EndIf If GuiCtrlRead($CheckRStore) = 1 Then _RemoteStorage() EndIf If GuiCtrlRead($CheckNet) = 1 Then _Network() EndIf If GuiCtrlRead($CheckUsers) = 1 Then _Users() EndIf If GuiCtrlRead($CheckOS) = 1 Then _OS() EndIf If GuiCtrlRead($CheckMSOffice) = 1 Then _MSOffice() EndIf If GuiCtrlRead($CheckSoftware) = 1 Then _Software() EndIf MsgBox(262208, "Completed Audit", "The audit process has finished." & @CRLF & "The information has been compiled into the file:" & @CRLF & $File, 0) Exit EndFunc Func _CreateFile() ;The output file Global $Output $Output = FileOpen($File, 2) ;File creation time FileWriteLine($Output, "File created on " & @MON & "/" & @MDAY & "/" & @YEAR) FileWriteLine($Output, "") ;The computer name FileWriteLine($Output, "Computer Name," & Chr(34) & @ComputerName & Chr(34)) FileWriteLine($Output, "") EndFunc Func _Hardware() ;Get info from WMIC $colCompSysPro = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x10 + 0x20) ;If variable is acceptable If IsObj($colCompSysPro) Then For $objCompSysPro In $colCompSysPro ;The Hardware Info ;Manufacturer FileWriteLine($Output, "Manufacturer," & Chr(34) & $objCompSysPro.Vendor & Chr(34)) ;Model If $objCompSysPro.Vendor = "Lenovo" Then $objModel = $objCompSysPro.Version Else $objModel = $objCompSysPro.Name EndIf FileWriteLine($Output, "Model," & Chr(34) & $objModel & Chr(34)) Next EndIf _SerialNumb($objCompSysPro.Vendor, $objCompSysPro.Name) FileWriteLine($Output, "") EndFunc Func _SerialNumb($Manufacturer, $Model) ;Get info from WMIC $colBios = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", 0x10 + 0x20) ;Serial Number or Service Tag If IsObj($colBios) Then For $objBios In $colBios If StringInStr($Manufacturer, "Lenovo") Then FileWriteLine($Output, "Lenovo Serial Number," & Chr(34) & $Model & $objBios.SerialNumber & Chr(34)) ElseIf StringInStr($Manufacturer, "Dell") Then FileWriteLine($Output, "Dell Service Tag," & Chr(34) & $objBios.SerialNumber & Chr(34)) Else FileWriteLine($Output, "Possible Serial Number," & Chr(34) & $objBios.SerialNumber & Chr(34)) EndIf Next EndIf EndFunc Func _CPU() $colCompSys = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", 0x10 + 0x20) If IsObj($colCompSys) Then For $objCompSys In $colCompSys ;The CPU FileWriteLine($Output, "Number of CPU," & Chr(34) & $objCompSys.NumberOfProcessors & Chr(34)) $CPUName = RegRead("HKLM64\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString") $CPUSpeed = _HZSuffix(RegRead("HKLM64\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz")) FileWriteLine($Output, "CPU,Type," & Chr(34) & $CPUName & Chr(34)) FileWriteLine($Output, ",Speed," & Chr(34) & $CPUSpeed & Chr(34)) FileWriteLine($Output, ",Number of CPU cores," & Chr(34) & $objCompSys.NumberOfLogicalProcessors & Chr(34)) FileWriteLine($Output, "") Next EndIf EndFunc Func _RAM() ;The RAM $RAMStats = MemGetStats() $RAMTotal = _RAMSuffix($RAMStats[1]) $RAMFree = _ByteSuffix($RAMStats[2]) $RAMVirtualTotal = _ByteSuffix($RAMStats[5]) $RAMVirtualFree = _ByteSuffix($RAMStats[6]) FileWriteLine($Output, "RAM,Total," & Chr(34) & $RAMTotal & Chr(34)) FileWriteLine($Output, ",Free," & Chr(34) & $RAMFree & Chr(34)) FileWriteLine($Output, ",Total Swap," & Chr(34) & $RAMVirtualTotal & Chr(34)) FileWriteLine($Output, ",Free Swap," & Chr(34) & $RAMVirtualFree & Chr(34)) FileWriteLine($Output, "") EndFunc Func _LocalStorage() Local $AllLocalDrives = "" Local $DriveSpaceTotal = "" Local $DriveSpaceFree = "" Local $DrivePercent = "" Local $DriveLabel = "" ;The Local Storage $DrivesPhysical = DriveGetDrive("FIXED") If Not @error Then For $a = 1 To $DrivesPhysical[0] $Drive = $DrivesPhysical[$a] $AllLocalDrives &= Chr(34) & $Drive & Chr(34) & "," $DriveSpaceTotal &= Chr(34) & _ByteSuffix(DriveSpaceTotal($Drive) * 1024) & Chr(34) & "," $DriveSpaceFree &= Chr(34) & _ByteSuffix(DriveSpaceFree($Drive) * 1024) & Chr(34) & "," $DrivePercent &= Chr(34) & 100 - StringFormat('%.2f', DriveSpaceFree($Drive) / DriveSpaceTotal($Drive) * 100) & "%" & Chr(34) & "," $DriveLabel &= Chr(34) & DriveGetLabel($Drive) & Chr(34) & "," Next FileWriteLine($Output, "Local Drives,Letter," & StringUpper($AllLocalDrives)) FileWriteLine($Output, ",Label," & $DriveLabel) FileWriteLine($Output, ",Total Space," & $DriveSpaceTotal) FileWriteLine($Output, ",Free Space," & $DriveSpaceFree) FileWriteLine($Output, ",Percent Full," & $DrivePercent) FileWriteLine($Output, "") EndIf EndFunc Func _RemoteStorage() Local $AllNetworkDrives = "" Local $MapDetails = "" Local $DriveSpaceTotal = "" Local $DriveSpaceFree = "" Local $DrivePercent = "" Local $DriveLabel = "" ;The Remote Storage $DrivesMapped = DriveGetDrive("NETWORK") If Not @error Then For $a = 1 To $DrivesMapped[0] $Drive = $DrivesMapped[$a] $MapDetails &= Chr(34) & DriveMapGet($Drive) & Chr(34) & "," $AllNetworkDrives &= Chr(34) & $Drive & Chr(34) & "," $DriveSpaceTotal &= Chr(34) & _ByteSuffix(DriveSpaceTotal($Drive) * 1024) & Chr(34) & "," $DriveSpaceFree &= Chr(34) & _ByteSuffix(DriveSpaceFree($Drive) * 1024) & Chr(34) & "," $DrivePercent &= Chr(34) & 100 - StringFormat('%.2f', DriveSpaceFree($Drive) / DriveSpaceTotal($Drive) * 100) & "%" & Chr(34) & "," $DriveLabel &= Chr(34) & DriveGetLabel($Drive) & Chr(34) & "," Next FileWriteLine($Output, "Network Drives,Letter," & StringUpper($AllNetworkDrives)) FileWriteLine($Output, ",Label," & $DriveLabel) FileWriteLine($Output, ",Network Path," & $MapDetails) FileWriteLine($Output, ",Total Space," & $DriveSpaceTotal) FileWriteLine($Output, ",Free Space," & $DriveSpaceFree) FileWriteLine($Output, ",Percent Full," & $DrivePercent) FileWriteLine($Output, "") EndIf EndFunc Func _Network() ;The Network $netItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapter Where PhysicalAdapter = True") If IsObj($netItems) then FileWriteLine($Output, "Network Connections") For $objnetItem In $netItems If StringInStr($objnetItem, "Bluetooth") Then ;ConsoleWrite("NO BLUETOOTH" & @CRLF) Else FileWriteLine($Output, ",Device: ," & Chr(34) & $objnetItem.Name & Chr(34)) FileWriteLine($Output, ",Name: ," & Chr(34) & $objnetItem.NetConnectionID & Chr(34)) FileWriteLine($Output, ",MACAddress: ," & Chr(34) & $objnetItem.MACAddress & Chr(34)) $netItemsDetail = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where Index = " & $objnetItem.DeviceID) For $objnetItemsDetail In $netItemsDetail FileWriteLine($Output, ",DHCP: ," & Chr(34) & $objnetItemsDetail.DHCPEnabled & Chr(34)) FileWriteLine($Output, ",DNSDomain: ," & Chr(34) & $objnetItemsDetail.DNSDomain & Chr(34)) If IsArray($objnetItemsDetail.IPAddress) Then For $objnetIP In $objnetItemsDetail.IPAddress FileWriteLine($Output, ",IP Address: ," & Chr(34) & $objnetIP & Chr(34)) Next Else FileWriteLine($Output, ",IP Address: ," & Chr(34) & $objnetItemsDetail.IPAddress & Chr(34)) EndIf If IsArray($objnetItemsDetail.DefaultIPGateway) Then For $objnetGateway In $objnetItemsDetail.DefaultIPGateway FileWriteLine($Output, ",Default Gateway: ," & Chr(34) & $objnetGateway & Chr(34)) Next Else FileWriteLine($Output, ",Default Gateway: ," & Chr(34) & $objnetItemsDetail.DefaultIPGateway & Chr(34)) EndIf Next FileWriteLine($Output, "") EndIf Next EndIf EndFunc Func _Users() ;The Users $FindUsers = _AccountEnum() If IsArray($FindUsers) Then If $FindUsers[0] > 0 Then $FilterGroup = "HomeGroupUser$" & @CR & "Guest" & @CR & "Default" $FilterGroupBreak = StringSplit($FilterGroup, @CR) For $a = 1 To $FilterGroupBreak[0] $FindFiltered = -1 $FindFiltered = _ArraySearch($FindUsers, $FilterGroupBreak[$a]) If $FindFiltered > -1 Then _ArrayDelete($FindUsers, $FindFiltered) $FindUsers[0] -= 1 EndIf Next $LocalUsers = "" FileWriteLine($Output, "Local Users,") For $a = 1 To $FindUsers[0] FileWriteLine($Output, "," & Chr(34) & $FindUsers[$a] & Chr(34)) ;$LocalUsers &= "," & Chr(34) & $FindUsers[$a] & Chr(34) Next FileWriteLine($Output, "") EndIf EndIf EndFunc Func _OS() ;The OS version $OSVersion = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName") FileWriteLine($Output, "Operating System,Version," & Chr(34) & $OSVersion & Chr(34)) ;The OS service pack FileWriteLine($Output, ",Service Pack," & Chr(34) & @OSServicePack & Chr(34)) ;The OS arch $OSArch = @OSArch FileWriteLine($Output, ",Architecture," & Chr(34) & $OSArch & Chr(34)) ;The OS Product Key $OSProductKey = _DecodeProductKey("Windows") FileWriteLine($Output, ",Product Key," & Chr(34) & $OSProductKey & Chr(34)) FileWriteLine($Output, "") EndFunc Func _MSOffice() Global $OfficeVersion $OfficeInstalled = False $OfficeXPCOA = _DecodeProductKey("Office XP") $Office2003COA = _DecodeProductKey("Office 2003") $Office2007COA = _DecodeProductKey("Office 2007") $Office2010COAX86 = _DecodeProductKey("Office 2010 x86") $Office2010COAX64 = _DecodeProductKey("Office 2010 x64") $Office2013COAX86 = _DecodeProductKey("Office 2013 x86") $Office2013COAX64 = _DecodeProductKey("Office 2013 x64") If $OfficeXPCOA <> "Product Not Found" And $OfficeXPCOA <> "" Then FileWriteLine($Output, "Office, Installed Version," & Chr(34) & $OfficeVersion & Chr(34)) FileWriteLine($Output, ",Product Key," & Chr(34) & $OfficeXPCOA & Chr(34)) $OfficeInstalled = True EndIf If $Office2003COA <> "Product Not Found" And $Office2003COA <> "" Then FileWriteLine($Output, "Office, Installed Version," & Chr(34) & $OfficeVersion & Chr(34)) FileWriteLine($Output, ",Product Key," & Chr(34) & $Office2003COA & Chr(34)) $OfficeInstalled = True EndIf If $Office2007COA <> "Product Not Found" And $Office2007COA <> "" Then FileWriteLine($Output, "Office, Installed Version," & Chr(34) & $OfficeVersion & Chr(34)) FileWriteLine($Output, ",Product Key," & Chr(34) & $Office2007COA & Chr(34)) $OfficeInstalled = True EndIf If $Office2010COAX86 <> "Product Not Found" And $Office2010COAX86 <> "" Then FileWriteLine($Output, "Office, Installed Version," & Chr(34) & $OfficeVersion & Chr(34)) FileWriteLine($Output, ",Product Key," & Chr(34) & $Office2010COAX86 & Chr(34)) $OfficeInstalled = True EndIf If $Office2010COAX64 <> "Product Not Found" And $Office2010COAX64 <> "" Then FileWriteLine($Output, "Office, Installed Version," & Chr(34) & $OfficeVersion & Chr(34)) FileWriteLine($Output, ",Product Key," & Chr(34) & $Office2010COAX64 & Chr(34)) $OfficeInstalled = True EndIf If $Office2013COAX86 <> "Product Not Found" And $Office2013COAX86 <> "" Then FileWriteLine($Output, "Office, Installed Version," & Chr(34) & $OfficeVersion & Chr(34)) FileWriteLine($Output, ",Product Key," & Chr(34) & $Office2013COAX86 & Chr(34)) $OfficeInstalled = True EndIf If $Office2013COAX64 <> "Product Not Found" Then FileWriteLine($Output, "Office,Installed Version," & Chr(34) & $OfficeVersion & Chr(34)) FileWriteLine($Output, ",Product Key," & Chr(34) & $Office2013COAX64 & Chr(34)) $OfficeInstalled = True EndIf If $OfficeInstalled == True Then FileWriteLine($Output, "If version and key did not show up") FileWriteLine($Output, "Please run a key finder to obtain it and paste is in here.") FileWriteLine($Output, "") EndIf EndFunc Func _DecodeProductKey($Product, $Offset = 0) Local $sKey[29], $Value = 0, $hi = 0, $n = 0, $i = 0, $dlen = 29, $slen = 15, $Result, $bKey, $iKeyOffset = 52, $RegKey Switch $Product Case "Windows" $bKey = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId") Case "Windows_DPid4" $bKey = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId4") $iKeyOffset = 0x328 Case "Windows_Def" $bKey = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DefaultProductKey", "DigitalProductId") Case "Windows_Def_DPid4" $bKey = RegRead("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DefaultProductKey", "DigitalProductId4") $iKeyOffset = 0x328 Case "Office XP" $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\10.0\Registration' If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\10.0\Registration' For $i = 1 To 100 $var = RegEnumKey($RegKey, $i) If @error <> 0 Then ExitLoop $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId') $OfficeVersion = RegRead($RegKey & '\' & $var, 'ProductName') If Not @error Then ExitLoop Next Case "Office 2003" $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\11.0\Registration' If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\11.0\Registration' For $i = 1 To 100 $var = RegEnumKey($RegKey, $i) If @error <> 0 Then ExitLoop $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId') $OfficeVersion = RegRead($RegKey & '\' & $var, 'ProductName') If Not @error Then ExitLoop Next Case "Office 2007" $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\12.0\Registration' If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\12.0\Registration' For $i = 1 To 100 $var = RegEnumKey($RegKey, $i) If @error <> 0 Then ExitLoop $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId') $OfficeVersion = RegRead($RegKey & '\' & $var, 'ProductName') If Not @error Then ExitLoop Next Case "Office 2010 x86" $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\14.0\Registration' If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Registration' For $i = 1 To 100 $var = RegEnumKey($RegKey, $i) If @error <> 0 Then ExitLoop $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId') $OfficeVersion = RegRead($RegKey & '\' & $var, 'ProductName') If Not @error Then ExitLoop Next $iKeyOffset = 0x328 Case "Office 2010 x64" If @OSArch <> 'x64' Then Return SetError(1, 0, "Product not found") $RegKey = 'HKLM64\SOFTWARE\Microsoft\Office\14.0\Registration' For $i = 1 To 100 $var = RegEnumKey($RegKey, $i) If @error <> 0 Then ExitLoop $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId') $OfficeVersion = RegRead($RegKey & '\' & $var, 'ProductName') If Not @error Then ExitLoop Next $iKeyOffset = 0x328 Case "Office 2013 x86" $RegKey = 'HKLM\SOFTWARE\Microsoft\Office\15.0\Registration' If @OSArch = 'x64' Then $RegKey = 'HKLM64\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Registration' For $i = 1 To 1024 $var = RegEnumKey($RegKey, $i) If @error <> 0 Then ExitLoop $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId') $OfficeVersion = RegRead($RegKey & '\' & $var, 'ConvertToEdition') If Not @error Then ExitLoop Next $iKeyOffset = 0x328 Case "Office 2013 x64" If @OSArch <> 'x64' Then Return SetError(1, 0, "Product not found") $RegKey = 'HKLM64\SOFTWARE\Microsoft\Office\15.0\Registration' For $i = 1 To 1024 $var = RegEnumKey($RegKey, $i) If @error <> 0 Then ExitLoop $bKey = RegRead($RegKey & '\' & $var, 'DigitalProductId') $OfficeVersion = RegRead($RegKey & '\' & $var, 'ConvertToEdition') If Not @error Then ExitLoop Next $iKeyOffset = 0x328 Case Else Return SetError(1, 0, "Product not supported") EndSwitch If Not BinaryLen($bKey) Then Return "" Local $aKeys[BinaryLen($bKey)] For $i = 0 To UBound($aKeys) - 1 $aKeys[$i] = Int(BinaryMid($bKey, $i + 1, 1)) Next Local Const $isWin8 = BitAND(BitShift($aKeys[$iKeyOffset + 14], 3), 1) $aKeys[$iKeyOffset + 14] = BitOR(BitAND($aKeys[$iKeyOffset + 14], 0xF7), BitShift(BitAND($isWin8, 2), -2)) $i = 24 Local $sChars = "BCDFGHJKMPQRTVWXY2346789", $iCur, $iX, $sKeyOutput, $iLast While $i > -1 $iCur = 0 $iX = 14 While $iX > -1 $iCur = BitShift($iCur, -8) $iCur = $aKeys[$iX + $iKeyOffset] + $iCur $aKeys[$iX + $iKeyOffset] = Int($iCur / 24) $iCur = Mod($iCur, 24) $iX -= 1 WEnd $i -= 1 $sKeyOutput = StringMid($sChars, $iCur + 1, 1) & $sKeyOutput $iLast = $iCur WEnd If $isWin8 Then $sKeyOutput = StringMid($sKeyOutput, 2, $iLast) & "N" & StringTrimLeft($sKeyOutput, $iLast + 1) EndIf Return StringRegExpReplace($sKeyOutput, '(\w{5})(\w{5})(\w{5})(\w{5})(\w{5})', '\1-\2-\3-\4-\5') EndFunc ;==>_DecodeProductKey Func _Software() ;The Installed Software $colSoftware = $objWMIService.ExecQuery("SELECT Name, Description, InstallDate, Version FROM Win32_Product", "WQL", 0x10 + 0x20) If IsObj($colSoftware) Then FileWriteLine($Output, "Software Installed") FileWriteLine($Output, ",Name,Description,Install Date,Version") For $objSoftware In $colSoftware FileWriteLine($Output, "," & $objSoftware.Name & "," & $objSoftware.Description & "," & $objSoftware.InstallDate & "," & $objSoftware.Version) Next EndIf EndFunc Func _HZSuffix($Bytes) Local $x, $BytesSuffix[2] = ["MHz", "GHz"] While $Bytes > 1000 $x += 1 $Bytes /= 1000 WEnd Return StringFormat('%.2f', $Bytes) & $BytesSuffix[$x] EndFunc ;==>_HZSuffix Func _ByteSuffix($Bytes) Local $x, $BytesSuffix[6] = ["KB", "MB", "GB", "TB", "PB"] While $Bytes > 1023 $x += 1 $Bytes /= 1024 WEnd Return StringFormat('%.2f', $Bytes) & $BytesSuffix[$x] EndFunc ;==>_ByteSuffix Func _RAMSuffix($Bytes) Local $x, $BytesSuffix[6] = ["KB", "MB", "GB", "TB", "PB"] While $Bytes > 1023 $x += 1 $Bytes /= 1024 WEnd $Bytes = Ceiling(StringFormat('%.2f', $Bytes)) $Bytes = StringFormat('%.2f', $Bytes) Return $Bytes & $BytesSuffix[$x] EndFunc ;==>_RAMSuffix