trashy Posted September 5, 2017 Posted September 5, 2017 Array 1 search source Windows\inf for all oem driver inf files Array 2 search source Windows\System32\DriverStore\FileRepository Goal is to use GUID from Array 1 to find matching Driver files in Array 2 and remove everything else I tried using StringInStr searching all ini files in FileRepository for GUID from array 1 So far that's a Bust! Could I not compare the 2 Arrays and remove everything from array 2 that doesn't match GUID of Array 1. I really don't know how to approach this, what's the easiest way to accomplish my goal. Don't think gonna figure this one out on my own. expandcollapse popup#include <Array.au3> #include <File.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> $DSTPATH = @HomeDrive & "\DriverBackup" $SRCPATH = @HomeDrive & "\Windows\inf" $SRC_PATH = @HomeDrive & "\Windows\System32\DriverStore\FileRepository" Local $hSRCFILEPATH = $SRCPATH, $hDSTFILEPATH = $DSTPATH, $aSRCDISKFILE Local $aSRCFILEPATH = _FileListToArrayRec($hSRCFILEPATH, "oem*.inf", 1, -10, 1, 1) Local $xArray[UBound($aSRCFILEPATH)][4] For $i = 1 To $aSRCFILEPATH[0] $xArray[$i][0] = $hSRCFILEPATH & '\' & $aSRCFILEPATH[$i] $xArray[$i][1] = $hSRCFILEPATH & '\' & StringLeft($aSRCFILEPATH[$i], StringInStr($aSRCFILEPATH[$i], '\', 0, -1) - 1) $xArray[$i][2] = IniRead($xArray[$i][0], 'Version', 'ClassGUID', 'Unknown') $xArray[$i][3] = IniRead($xArray[$i][0], 'Version', 'DriverVer', 'Unknown') Global $xArray Next Local $hSRC_FILEPATH = $SRC_PATH, $hDST_FILEPATH = $DSTPATH, $aSRC_DISKFILE Local $aSRC_FILEPATH = _FileListToArrayRec($hSRC_FILEPATH, "*.inf", 1, -10, 1, 1) Local $yArray[UBound($aSRC_FILEPATH)][4] For $i = 1 To $aSRC_FILEPATH[0] $yArray[$i][0] = $hSRC_FILEPATH & '\' & $aSRC_FILEPATH[$i] $yArray[$i][1] = $hSRC_FILEPATH & '\' & StringLeft($aSRC_FILEPATH[$i], StringInStr($aSRC_FILEPATH[$i], '\', 0, -1) - 1) $yArray[$i][2] = IniRead($yArray[$i][0], 'Version', 'ClassGUID', 'Unknown') $yArray[$i][3] = IniRead($yArray[$i][0], 'Version', 'DriverVer', 'Unknown') Global $yArray Next _ArrayDisplay($xArray, 'Array 1', '', 0, Default, 'Source inf|Source Path|GUID|DriverVer') _ArrayDisplay($yArray, 'Array 2', '', 0, Default, 'Source inf|Source Path|GUID|DriverVer') For $a = UBound($yArray) - 1 To 0 Step -1 For $b = 0 To UBound($xArray) - 1 If Not $yArray[$a] = $xArray[$b] Then _ArrayDelete($yArray, $a) ExitLoop EndIf Next Next _ArrayDisplay($yArray, 'Array 2', '', 0, Default, 'Source inf|Source Path|GUID|DriverVer')
trashy Posted September 5, 2017 Author Posted September 5, 2017 I found a couple examples I think you are dealing with 1 dimensional arrays. What I posted wasn't the real deal my arrays are 10 columns everything from file paths to driver arch. I think that's my problem is the multi dimension array. New to Arrays don't really understand it yet. Don't know what I'm doing half the time any ways. I'm afraid this may be beyond my comprehension for now. Workaround read .cat from oem*.inf and search driverstore for dir containing cat file. I'm trying to export 3rd party drivers from windows driver store.
trashy Posted September 5, 2017 Author Posted September 5, 2017 @rootx Studied that example a couple times not quite comprehending it yet.
rootx Posted September 5, 2017 Posted September 5, 2017 I posted wasn't the real deal my arrays are 10 columns everything from file paths to driver arch. I think that's my problem is the multi dimension array 1. you must compare the name of the file colums number one.... use _pathsplit func... in a loop or a regexp then you can compare it EX. oem0.inf to oem0.inf and not c:\windows....oem0.inf versus c:\windows32 ....oem0.inf https://www.autoitscript.com/autoit3/docs/libfunctions/_PathSplit.htm 2. Use array search and select wich colums you want. https://www.autoitscript.com/autoit3/docs/libfunctions/_ArraySearch.htm
Gianni Posted September 5, 2017 Posted September 5, 2017 ... change your final checking loops like this: Local $bFound For $a = UBound($yArray) - 1 To 0 Step -1 $bFound = False For $b = 0 To UBound($xArray) - 1 If $yArray[$a][2] = $xArray[$b][2] Then $bFound = True ExitLoop EndIf Next If Not $bFound Then _ArrayDelete($yArray, $a) Next _ArrayDisplay($yArray, 'Array 2', '', 0, Default, 'Source inf|Source Path|GUID|DriverVer') trashy 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
trashy Posted September 5, 2017 Author Posted September 5, 2017 @Chimp Thank You I see the little tweaks and how you used the true and false, maybe I learned something. Could be dangerous! Your example put me well on the way. expandcollapse popup#include <Array.au3> #include <File.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> $DSTPATH = @HomeDrive & "\DriverBackup" $SRCPATH = @HomeDrive & "\Windows\inf" $SRC_PATH = @HomeDrive & "\Windows\System32\DriverStore\FileRepository" Local $hSRCFILEPATH = $SRCPATH, $hDSTFILEPATH = $DSTPATH, $aSRCDISKFILE Local $aSRCFILEPATH = _FileListToArrayRec($hSRCFILEPATH, "oem*.inf", 1, -10, 1, 1) Local $xArray[UBound($aSRCFILEPATH)][6] For $i = 1 To $aSRCFILEPATH[0] $xArray[$i][0] = $hSRCFILEPATH & '\' & $aSRCFILEPATH[$i] $xArray[$i][1] = $hSRCFILEPATH & '\' & StringLeft($aSRCFILEPATH[$i], StringInStr($aSRCFILEPATH[$i], '\', 0, -1) - 1) $xArray[$i][2] = IniRead($xArray[$i][0], 'Version', 'ClassGUID', 'Unknown') $xArray[$i][3] = IniRead($xArray[$i][0], 'Version', 'DriverVer', 'Unknown') $xArray[$i][4] = IniRead($xArray[$i][0], 'Version', 'Class', 'Misc') $xArray[$i][5] = IniRead($xArray[$i][0], 'Version', 'Provider', 'Unknown_Provider') If StringInStr($xArray[$i][5], "%") Then $test3 = StringRegExpReplace($xArray[$i][5], "%", "") $test4 = IniRead($xArray[$i][0], 'Strings', $test3, 'Misc') $xArray[$i][5] = $test4 EndIf Global $xArray Next Local $hSRC_FILEPATH = $SRC_PATH, $hDST_FILEPATH = $DSTPATH, $aSRC_DISKFILE Local $aSRC_FILEPATH = _FileListToArrayRec($hSRC_FILEPATH, "*.inf", 1, -10, 1, 1) Local $yArray[UBound($aSRC_FILEPATH)][6] For $i = 1 To $aSRC_FILEPATH[0] $yArray[$i][0] = $hSRC_FILEPATH & '\' & $aSRC_FILEPATH[$i] $yArray[$i][1] = $hSRC_FILEPATH & '\' & StringLeft($aSRC_FILEPATH[$i], StringInStr($aSRC_FILEPATH[$i], '\', 0, -1) - 1) $yArray[$i][2] = IniRead($yArray[$i][0], 'Version', 'ClassGUID', 'Unknown') $yArray[$i][3] = IniRead($yArray[$i][0], 'Version', 'DriverVer', 'Unknown') $yArray[$i][4] = IniRead($yArray[$i][0], 'Version', 'Class', 'Misc') $yArray[$i][5] = IniRead($yArray[$i][0], 'Version', 'Provider', 'Unknown_Provider') If StringInStr($yArray[$i][5], "%") Then $test3 = StringRegExpReplace($yArray[$i][5], "%", "") $test4 = IniRead($yArray[$i][0], 'Strings', $test3, 'Misc') $yArray[$i][5] = $test4 EndIf Global $yArray Next _ArrayDisplay($xArray, 'Array 1', '', 0, Default, 'Source inf|Source Path|GUID|DriverVer|Class|Providr') _ArrayDisplay($yArray, 'Array 2', '', 0, Default, 'Source inf|Source Path|GUID|DriverVer|Class|Providr') Local $bFound For $a = UBound($yArray) - 1 To 0 Step -1 $bFound = False For $b = 0 To UBound($xArray) - 1 If $yArray[$a][2] = $xArray[$b][2] Then $bFound = True ExitLoop EndIf Next If Not $bFound Then _ArrayDelete($yArray, $a) Next _ArrayDisplay($yArray, 'Array 2', '', 0, Default, 'Source inf|Source Path|GUID|DriverVer|Class|Providr') Local $bFound For $a = UBound($yArray) - 1 To 0 Step -1 $bFound = False For $b = 0 To UBound($xArray) - 1 If $yArray[$a][5] = $xArray[$b][5] Then $bFound = True ExitLoop EndIf Next If Not $bFound Then _ArrayDelete($yArray, $a) Next _ArrayDisplay($yArray, 'Array 2', '', 0, Default, 'Source inf|Source Path|GUID|DriverVer|Class|Providr') Local $bFound For $a = UBound($yArray) - 1 To 0 Step -1 $bFound = False For $b = 0 To UBound($xArray) - 1 If $yArray[$a][3] = $xArray[$b][3] Then $bFound = True ExitLoop EndIf Next If Not $bFound Then _ArrayDelete($yArray, $a) Next _ArrayDisplay($yArray, 'Array 2', '', 0, Default, 'Source inf|Source Path|GUID|DriverVer|Class|Providr')
trashy Posted September 5, 2017 Author Posted September 5, 2017 I wasn't sure if my logic was sound but I was headed in the right direction and getting close. I would have never figured it out on my own, thanks again everyone. This will turn into a nice little driver backup program
Luigi Posted September 10, 2017 Posted September 10, 2017 Maybe something like this? expandcollapse popup#include <Array.au3> ; Autor: Luigi ; source: http://forum.autoitbrasil.com/index.php?/topic/1236-verificar-igualdades-e-diferencas-de-posicoes-entre-2-arrays/ Global $arr1[4][2] = [[0, 0],[0, 1],[1, 0],[1, 1]] Global $arr2[4][2] = [[1, 1],[1, 2],[2, 1],[2, 2]] dif($arr1, $arr2) Func conjunto($arr) Local $reply[1] For $xx = 0 To UBound($arr, 1) - 1 Local $num = '' For $yy = 0 To UBound($arr, 2) - 1 $num &= $arr[$xx][$yy] & '.' Next _ArrayAdd($reply, StringTrimRight($num, 1)) Next _ArrayDelete($reply, 0) Return $reply EndFunc ;==>conjunto Func dif($aa1, $aa2) $aa1 = conjunto($aa1) $aa2 = conjunto($aa2) Local $aOnlyA[1], $aCommom[1], $aOnlyB[1], $reply[2] For $xx = 0 To UBound($aa1) - 1 If _ArraySearch($aa1, $aa2[$xx]) <> -1 Then _ArrayAdd($aCommom, $aa2[$xx]) Next _ArrayDelete($aCommom, 0) _ArrayDisplay($aCommom, 'o que há de comum entre A & B', 1) For $xx = 0 To UBound($aa1) - 1 If _ArraySearch($aCommom, $aa1[$xx]) == -1 Then _ArrayAdd($aOnlyA, $aa1[$xx]) If _ArraySearch($aCommom, $aa2[$xx]) == -1 Then _ArrayAdd($aOnlyB, $aa2[$xx]) Next $reply[0] = toArray($aOnlyA) _ArrayDisplay($reply[0], 'o que existe somente em A, e que não faz parte de B') $reply[1] = toArray($aOnlyB) _ArrayDisplay($reply[1], 'o que existe somente em B, e que não faz parte de A') Return $reply EndFunc ;==>dif Func toArray($input) Local $arr[1][2], $temp For $xx = 1 To UBound($input) - 1 ReDim $arr[UBound($arr) + 1][2] $temp = StringSplit($input[$xx], '.', 2) ;~ ConsoleWrite($temp[0] & $temp[1] & @LF) $arr[$xx][0] = $temp[0] $arr[$xx][1] = $temp[1] Next _ArrayDelete($arr, 0) Return $arr EndFunc ;==>toArray Visit my repository
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