jazzyjeff Posted September 29, 2014 Share Posted September 29, 2014 (edited) I am trying to enumerate, and/or get a count of registry subkeys. I have never had this problem before, but I am unable to subkeys that are definitely there. I am starting my script so it is running elevated, but this makes no difference. Here is the code that I am using to get the subkey count. $rKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Userdata\S-1-5-18\Products") $arrayRKEY = _WinAPI_RegQueryInfoKey($rKey) If IsArray($arrayRKEY) Then _ArrayDisplay($arrayRKEY) Else MsgBox(0,"","No array" & @CR & "Error: " & @error & @CR & "Extended Error: " & @extended) EndIf The problem seems to be with the registry path, and If I change the path to this: $rKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion") It works fine. I don't get why I cannot get the information from the path I want. Attached is a screenshot proving that I have numerous subkeys. has anyone else seen this, or have a way to fix it? Thanks, Jeff Edited September 29, 2014 by jazzyjeff Link to comment Share on other sites More sharing options...
Danyfirex Posted September 29, 2014 Share Posted September 29, 2014 why not AutoIt registry funtions? Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
BrewManNH Posted September 29, 2014 Share Posted September 29, 2014 (edited) Have you tried it with RegEnumKey instead? Local $sSubKey = "", $i = 1 While 1 $sSubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Userdata\S-1-5-18\Products", $i) If @error Then ExitLoop ConsoleWrite("SubKey #" & $i & " under HKLM\SOFTWARE: " & $sSubKey & @CRLF) $i += 1 WEnd Edited September 29, 2014 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jazzyjeff Posted September 29, 2014 Author Share Posted September 29, 2014 Thanks for your quick responses. The built in Reg Functions were the first thing I tried, but I wasn't having success, so I started looking at the API functions. BrewmanNH - Using the While loop with RegEnumKey was the first thing I tried, but I had no success. I just tried again with your code, but it still doesn't work. Link to comment Share on other sites More sharing options...
jazzyjeff Posted September 29, 2014 Author Share Posted September 29, 2014 I just tried rebooting my machine in case there was something causing the problem there, but that didn't help. Link to comment Share on other sites More sharing options...
Exit Posted September 29, 2014 Share Posted September 29, 2014 Would you please so kind to post a complete script. Then we could try and see, where the error is. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
jazzyjeff Posted September 29, 2014 Author Share Posted September 29, 2014 I certainly could post all my code, but you're assuming there is something else wrong with the code , but that is not the case. This is the only piece of code that is failing. Here is all the code of a script I am using: #include <WinAPIReg.au3> #include <Array.au3> Local $sHKLM_Inst = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer" Local $sHKLM_UnInst64 = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" Local $sHKLM_UnInst = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $rKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Userdata\S-1-5-18\Products") $arrayRKEY = _WinAPI_RegQueryInfoKey($rKey) If IsArray($arrayRKEY) Then _ArrayDisplay($arrayRKEY) Else MsgBox(0, "", "No array" & @CR & "Error: " & @error & @CR & "Extended Error: " & @extended) EndIf _WinAPI_RegCloseKey($rKey) Local $sSubKey = "", $i = 1 While @error <> 0 $sSubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Userdata\S-1-5-18\Products", $i) MsgBox(0, "", "SubKey #" & $i & " under HKLM\SOFTWARE: " & $sSubKey & @CRLF) $i += 1 WEnd I tried running a Reg Query from command line and this populates the subkeys fine... It's kind of a crappy way to get the information, but I may have to resort to exporting the keys from here. It seems like there is probably a configuration setting on my PC that isn't working. I am going to test this code on another box to see if that is also having problems reading back the registry keys to me. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 29, 2014 Share Posted September 29, 2014 Your While loop is wrong, @error will never happen so you're going to get stuck in it forever. Write it the way I wrote it and you'll be able to get out of the loop when you run out of keys to enumerate. BTW, my code as written works on my computer. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Exit Posted September 29, 2014 Share Posted September 29, 2014 Seems to be a 64 bit OS. Try this: for $i=1 to 9999 $sSubKey = RegEnumKey("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Userdata\S-1-5-18\Products", $i) If @error Then ExitLoop ConsoleWrite($sSubKey & @CRLF) Next App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
jazzyjeff Posted September 29, 2014 Author Share Posted September 29, 2014 Exit. Thank you very much. The registry key I used was missing the 64... I am sure I didn't have to do that before. Oh well it's working now :-) Thanks very much 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