BigfootMoeron Posted February 21, 2008 Posted February 21, 2008 None of the 3 Reg read commands (regenumkey, regenumval, regread) in the help file seems to be able to assist me in determining if a SPECIFIC reg key exists (and the RegSearch function seems overkill). I am scripting an install of Acrobat Reader's latest patched version. I just need to know if the specific KEY: HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\8.0\Installer\Updates\812 exists. If so, I will exit, if not I will call the install and get it on the system. Will I have to return all keys under "Updates" using a RegEnumKey loop and search for 812, or is there a more direct way? Sorry for the noob Q!!!
muhmuuh Posted February 21, 2008 Posted February 21, 2008 Hello! I think you can use RegRead() . It will return "" if the key doesn't exist. I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more.
BigfootMoeron Posted February 22, 2008 Author Posted February 22, 2008 Yes, but RegRead seems to return "" if the key DOES exist too! Any other ideas out there?
Siao Posted February 22, 2008 Posted February 22, 2008 (edited) RegRead --------------------------------------------------------------------------------Reads a value from the registry.RegRead ( "keyname", "valuename" )Parameterskeyname The registry key to read. valuename The value to read. Return ValueSuccess: Returns the requested registry value. @EXTENDED is set to the type of the value $REG_... . These types are defined in the "Constants.au3" include file. Failure: Returns "" and sets the @error flag: 1 if unable to open requested key 2 if unable to open requested main key 3 if unable to remote connect to the registry -1 if unable to open requested value -2 if value type not supported Edited February 22, 2008 by Siao "be smart, drink your wine"
GEOSoft Posted February 22, 2008 Posted February 22, 2008 RegEnumKey ( "keyname", 1 ) If @Error Then Do whatever Else Do something Else EndIf From the help file entry for RegEnumKey Success: Returns the requested subkey name.. Failure: Returns an error message string and sets the @error flag: 1 if unable to open requested key 2 if unable to open requested main key 3 if unable to remote connect to the registry -1 if unable to retrieve requested subkey (key instance out of range) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
BigfootMoeron Posted February 22, 2008 Author Posted February 22, 2008 I understand, but as I said in the original request, I don't want to have to enumerate the keys, I want to look for a specific key. I want to know if the key named "812" exists, not have to parse up to 20 keys in a FOR loop and check to see any of the iterations return "812".
GEOSoft Posted February 22, 2008 Posted February 22, 2008 I understand, but as I said in the original request, I don't want to have to enumerate the keys, I want to look for a specific key.I want to know if the key named "812" exists, not have to parse up to 20 keys in a FOR loop and check to see any of the iterations return "812".And I'm say that all you have to do is Enum the first instance to get a return value. Read RegEnumKey() in the help file. You are getting what you were trying to accomplish with RegRead(), which won't do it. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
BigfootMoeron Posted February 22, 2008 Author Posted February 22, 2008 Thank you. There could be up to 20 keys with the one labeled "812" I am looking for. There could be 801, 802, 803, ... 811, 812, ... 819, 820 So enumerating just the first key does not guarantee that 812 is or is not one of those keys. I guess I just need to run a for loop and compare values. Wonder why there is no direct way to look for a specific key. Thanks anyway.
GEOSoft Posted February 22, 2008 Posted February 22, 2008 Thank you.There could be up to 20 keys with the one labeled "812" I am looking for. There could be 801, 802, 803, ... 811, 812, ... 819, 820So enumerating just the first key does not guarantee that 812 is or is not one of those keys.I guess I just need to run a for loop and compare values.Wonder why there is no direct way to look for a specific key.Thanks anyway.Post the actual key (full path) that you are looking for and I will give you an example. You shouldn't need a loop. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Siao Posted February 22, 2008 Posted February 22, 2008 (edited) I don't understand what's so hard to grasp: RegRead('HKLM\Software\Blah','') If @error = 1 Then Msgbox(0, 'Error', 'Key "HKLM\Software\Blah" not found.') Edited February 22, 2008 by Siao mr-es335 1 "be smart, drink your wine"
mikiutama Posted February 22, 2008 Posted February 22, 2008 (edited) this is not my script... thanks to whoever made this... expandcollapse popup#include <GUIConstants.au3> GUICreate("Registry Search",500,80) $info_text = GUICtrlCreateLabel("",10,10,480,60) GUISetState() Global $found = "" SearchReg("HKLM","Acrobat Reader\8.0\Installer\Updates\812") ;SearchReg("HKLM","Installer\Updates\812") GUIDelete() Msgbox(0,"",$found) Exit ;***************************************************** ; Recursive search-function ;***************************************************** Func SearchReg($startkey,$searchval) Local $val,$i,$key,$z $i = 1 While 1 $key = RegEnumKey($startkey,$i) If @error <> 0 Then ExitLoop GUICtrlSetData($info_text,$startkey & "\" & $key) $z = 1 While 1 $val = RegEnumVal($startkey & "\" & $key,$z) If @error <> 0 Then ExitLoop If StringInStr($val,$searchval) Then $found = $found & "ValueName, " & $startkey & "\" & $key & ", " & $val & @LF $readval = RegRead($startkey & "\" & $key,$val) If $readval <> "" And StringInStr($readval,$searchval) Then $found = $found & "Value, " & $startkey & "\" & $key & ", " & $val & ", " & $readval & @LF $z = $z + 1 WEnd SearchReg($startkey & "\" & $key,$searchval) $i = $i + 1 WEnd ;Sleep(1); just 1 idle milli second -> not used at the moment EndFunc Edited February 22, 2008 by mikiutama
GEOSoft Posted February 22, 2008 Posted February 22, 2008 I don't understand what's so hard to grasp:RegRead('HKLM\Software\Blah','')If @error = 1 Then Msgbox(0, 'Error', 'Key "HKLM\Software\Blah" not found.')Absolutly correct. I forgot all about the @Error return for RegRead(). The OP is correct that if the key doesn't exist then RegRead will return "", but it also sets @Error. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
BigfootMoeron Posted February 22, 2008 Author Posted February 22, 2008 I don't understand what's so hard to grasp:RegRead('HKLM\Software\Blah','')If @error = 1 Then Msgbox(0, 'Error', 'Key "HKLM\Software\Blah" not found.')What's so hard to grasp? How about I am an idiot. :-)Sorry, I understand now.I never tried the RegRead without a "valuename" ... read the help file and though it never specified it, I ASSUMED (yes, I know what happens when I assume) that the valuename was required.What you did above was perfect.Thank you so much and sorry again for being a bonehead!!
BigfootMoeron Posted February 22, 2008 Author Posted February 22, 2008 PS - I see now in the help file that I can use "" for the DEFAULT value -- never associated DEFAULT with just the name of the key. I feel like a moron.....
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