frankpintosr Posted May 1, 2008 Share Posted May 1, 2008 Hello All, So for every SID on the HKEY_Users I want to read the whole ODBC folder and everything under it, and write that info to a log file. I think I need to use some kind of wildcard with regread, does anyone know if this will work and how? Or have any suggections? Thanks!! Frank Link to comment Share on other sites More sharing options...
James Posted May 1, 2008 Share Posted May 1, 2008 Wildcards aren't used in AutoIt, well not as * anyway. You need to look at RegRead() and RegEnumKey(). Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 1, 2008 Share Posted May 1, 2008 Hello All,So for every SID on the HKEY_Users I want to read the whole ODBC folder and everything under it, and write that info to a log file. I think I need to use some kind of wildcard with regread, does anyone know if this will work and how? Or have any suggections?Thanks!!FrankA recursive _RegSearch(). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
weaponx Posted May 1, 2008 Share Posted May 1, 2008 Wildcards aren't used in AutoIt, well not as * anyway. You need to look at RegRead() and RegEnumKey().You may want to check the helpfile again (READ: FileFindFirstFile).Dumping the contents of the subkeys is going to require an ugly recursive function. Link to comment Share on other sites More sharing options...
weaponx Posted May 1, 2008 Share Posted May 1, 2008 You could use the Ini functions but unfortunately they have limitations and only a portion of your registry export will be evaluated. $RegFile = @MyDocumentsDir & "\test.reg" RunWait('REG EXPORT HKU "' & $RegFile & '"') If FileExists($RegFile) Then $sections = IniReadSectionNames($RegFile) Const $Mask = "Software\ODBC" For $X = 1 to $sections[0] If StringInStr($sections[$X], $Mask) Then ConsoleWrite($sections[$X] & @CRLF) Else IniDelete ($RegFile, $sections[$X]) EndIf Next EndIf Link to comment Share on other sites More sharing options...
frankpintosr Posted May 1, 2008 Author Share Posted May 1, 2008 You are awsome, thanks so much for the help and code. This works perfectly. I added the following from the helpfile to export the info to a file. Granted, it is not a txt file, which would be better, but this is working for me untill I figure out the code to create a txt file. I saw the script to write to a txt file, just not create one. Thanks again!!Word document creation and write results to it:CODE#include <Word.au3>$oWordApp = _WordCreate (@ScriptDir & "\Test.doc", 0, 0)$oDoc = _WordDocGetCollection ($oWordApp, 0)$oDoc.Range.insertAfter ($Results)_WordQuit ($oWordApp, -1)A recursive _RegSearch(). Link to comment Share on other sites More sharing options...
weaponx Posted May 1, 2008 Share Posted May 1, 2008 How does Word come into play? I wouldn't trust your Word document not to populated with mysterious markup and formatting. Use FileWrite() or FileWriteLine() instead. In this case _RegSearch() returns an @LF delimited string. $Results = _RegSearch($SearchKey, $SearchString) FileWrite("out.txt", $Results) -or- $Results = _RegSearch($SearchKey, $SearchString) $split = StringSplit($Results, @LF) For $X = 1 to $split[0] FileWriteLine("out.txt", $split[$X] Next Link to comment Share on other sites More sharing options...
frankpintosr Posted May 1, 2008 Author Share Posted May 1, 2008 Fantastic, the second piece of code works great. It is missing a close paran in the fileWrite line, but that was an easy find. I am reposting incase someone else wants to copy the script. In this case _RegSearch() returns an @LF delimited string. $split = StringSplit($Results, @LF) For $X = 1 to $split[0] FileWriteLine("c:\userinfo.txt", $split[$X]) Next So now I am only left with getting all the values under the keys I located. I tried the following but I get an error saying the string is too long. For $a= 1 to 100 $keys = RegEnumVal($Results, $a) If @error <> 0 then ExitLoop Next MsgBox(64, "_RegSearch() Test", "Results of searching registry:" & @CRLF & _ "In: " & $SearchKey & @CRLF & _ "For: " & $SearchString & @CRLF & _ "Time taken (in seconds): " & $Timer & @CRLF & _ "---------------------------------------" & @CRLF & _ $keys) How does Word come into play? I wouldn't trust your Word document not to populated with mysterious markup and formatting. Use FileWrite() or FileWriteLine() instead. In this case _RegSearch() returns an @LF delimited string. $Results = _RegSearch($SearchKey, $SearchString) FileWrite("out.txt", $Results) -or- $Results = _RegSearch($SearchKey, $SearchString) $split = StringSplit($Results, @LF) For $X = 1 to $split[0] FileWriteLine("out.txt", $split[$X] Next 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