Tr33x0rs Posted August 8, 2017 Share Posted August 8, 2017 I apologize in advance if I'm overlooking something really stupid or easy, I'm just getting into programming again. I'm going off of an example posted here: by ViciousXUSMC which I have tailored to suite my needs. It's working well although the string I need to search for includes quotation marks and many spaces. The Exact String I am searching for is: "Twist Y" = "31.5" I have tried different variations of declaring the $sSearch variable, including using ' instead of " with no luck. Here is my current code: #Include <Array.au3> #Include <Constants.au3> $sSearch = '"Twist Y" = "31.5"' $sFilePath = "C:\Users\Tr33x0rs\Desktop\IG Config Locator\FAAigFiles\Setup" $sMask = "ig.reg" $sResultsFile = "C:\Users\Tr33x0rs\Desktop\IG Config Locator\Results.txt" $aFiles = _FindInFile($sSearch, $sFilePath, $sMask) ;_ArrayDisplay($aFiles) ;Uncomment to see results If FileExists($sResultsFile) Then FileDelete($sResultsFile) $hFile = FileOpen($sResultsFile, $FO_APPEND) FileWrite($hFile, "Scan Compiled On " & @MON & "/" & @MDAY & "/" & @YEAR & " At " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF) FileWrite($hFile, "Result Files Containing String: " & $sSearch & @CRLF & @CRLF) For $i = 1 to $aFiles[0] FileWrite($hFile, $aFiles[$i] & @CRLF) Next FileClose($hFile) Func _FindInFile($sSearch, $sFilePath, $sMask = '*', $fRecursive = True, $fLiteral = True, $fCaseSensitive = Default, $fDetail = Default) Local $sCaseSensitive = $fCaseSensitive ? '' : '/i', $sDetail = $fDetail ? '/n' : '/m', $sRecursive = ($fRecursive Or $fRecursive = Default) ? '/s' : '' If $fLiteral Then $sSearch = ' /c:' & $sSearch EndIf If $sMask = Default Then $sMask = '*' EndIf $sFilePath = StringRegExpReplace($sFilePath, '[\\/]+$', '') & '\' Local Const $aMask = StringSplit($sMask, ';') Local $iPID = 0, $sOutput = '' For $i = 1 To $aMask[0] $iPID = Run(@ComSpec & ' /c ' & 'findstr ' & $sCaseSensitive & ' ' & $sDetail & ' ' & $sRecursive & ' "' & $sSearch & '" "' & $sFilePath & $aMask[$i] & '"', @SystemDir, @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput &= StdoutRead($iPID) Next Return StringSplit(StringStripWS(StringStripCR($sOutput), BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)), @LF) EndFunc ;==>_FindInFile Any help is greatly appreciated! 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