Jump to content

read registry subkeys and write to array


Recommended Posts

Hi

i have a registry key like HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content. This key has Subkeys. Each Subkeys has Values.

I would like to create a table like;

1.line of table: Name of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey1

1.Column: 1.Value of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey1

2.Column: 2.Value of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey1

3.Column: 3.Value of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey1

4.Column: 4.Value of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey1

If subkey1 has no values go to HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey2

2.line of table: Name of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey2

1.Column: 1.Value of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey2

2.Column: 2.Value of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey2

3.Column: 3.Value of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey2

4.Column: 4.Value of HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey2

If subkey1 has no values go to HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content\Subkey3

etc.

this Code works but the msgbox displays each Subkey in your own msgbox.

FOR $i=1 to 5

$var=RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content",$i)
If @error <> 0 then ExitLoop
MsgBox(0, "Test", $var)
Next

tkanks for tipps.

Link to comment
Share on other sites

Hi kneze,

look at that code:

Dim $var, $text, $i
while 1
  $i += 1
  $var=RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Sample\content",$i)
  If @error <> 0 then ExitLoop
  $text = $text & @CRLF & $var
Wend
MsgBox(0,"Keys:", $text)

You can add the values to an existing variable. This is a start. Have fun coding the rest. :unsure:

Edited by Hannes123
Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

hi hannes

your code works. i have your script expanded but var1 doesnt Work.

when i try $var1=RegRead("HKEY_LOCAL_MACHINE\Sample\content", "Installation_status") it works

but $var1=RegRead($var, "Installation_status") doesnt work.

Dim $var, $var1, $text, $i

while 1
 $i += 1
 $var=RegEnumKey("HKEY_LOCAL_MACHINE\Sample\content",$i)
$var1=RegRead($var, "Installation_status")
If @error <> 0 then ExitLoop
$text = $text & @CRLF & $var & $var1 & @CRLF
Wend
MsgBox(0,"Keys:", $text)
Link to comment
Share on other sites

ok, i have now a script with all function and output that i need.

i have an function in my script to check if remote computer is online.

but the script don't exit if client isn't online.

#include "array.au3"
 Case $Button_1

    ;save Variable $Input as $PCNamen
    $CPname = GuiCtrlRead($Input)
                    
    If $CPname = "" Then
           MsgBox(0, "Error", "Missing Computer Nr. ")
    Else    
       MsgBox(0, "Info", "batch1 will be run.")
                
        $var = Ping($CPname,250)
        
                   If @error = 0 Then   
            Msgbox(0,"Status","Computer not online& $var)
              Else
                            
            local $var, $var1,$var2, $text, $i, $j 
                
        while 3
          $j += 1
          $var2=RegEnumKey("\\"&$cpname&"\HKEY_LOCAL_MACHINE\Sample\content",$j)
          If @error <> 0 then ExitLoop
        Wend     

            Local  $arr[$j][2]
            
            ; Populate array somehow
            $arr[0][0] = "key"
            $arr[0][1] = "status"

              while 4
            $i += 1
            $var=RegEnumKey("\\"&$cpname&"\HKEY_LOCAL_MACHINE\Sample\content",$i)
            If @error <> 0 then ExitLoop
            $var1 = RegRead("\\"&$cpname&"\HKEY_LOCAL_MACHINE\Sample\content\"&           
$var, "Installation_status" )
 
            $arr[$i][0] = $var
            $arr[$i][1] = $var1

               Wend
                
                EndIf
            EndIf
            _ArrayDisplay ($arr,"comment")
Edited by kneze
Link to comment
Share on other sites

  • 1 year later...

Well, at least this time the thread is only 1 1/2 years old instead of 2 years. Necroposting is frowned upon, and so is self-promotion.

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 Gude
How 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

Well, at least this time the thread is only 1 1/2 years old instead of 2 years

Not trying to be a smart OK hmmmmmm Not all users must necessarily do 4600 posts indicate ONLY the help of autoit ;), if I want to play you change irony pointing this and a few days ago OK, as already done just NOW ;) OKKK

Necroposting is frowned upon

Not a Necroposting OKKK, I think I have already explained very well here I know you are now pretended not to understand ok ;) I do not understand the reasons why you keep this discussion I believe and already clarified here OK

or I have advice for you, best to try to spend time on other things instead of the ironic with users around in the forum OK

and so is self-promotion.

and forbidden to give a solution? (because you are not able to give a solution and prohibited to do it the other) but the real reason why put the link here was this, and you read that right to

the point is that I before making the RegEnumKeyEx, or read in forums and looking for RegEnumKey, have left 20-30 topics ect ect, after or fate to me that RegEnumKeyEx, after I had already in Firefox browser these posts and precisely or posted here and in another post

always with idea to be of help, because I'm confused actually looking RegEnumKey + array ect ect, there are many topics with all the hanging question and all without a real solution

why because you do not like it, or because you're jealous (you must offending other users?, how fucking dare you make judgments for another user without knowing it?) what the fuck do I know (Luckily you're not a moderator or admin here, if I delete the account immediately, no nerves to break with guys like you around), this says it all about the reason why ect ect ect (I owe you? also delete the )

not nice to spend all the time with the purpose to break other OKKKK, not told that he must always speak ;) when you do not do or say, still without speaking and better OK

PS:I'm really really sorry (for real), wrong your nickname with that of guinness, guinness was not, but it was you you did servility with the story of , the post written here and for you OK (fuck I do not see where the crime here, and a crime to post a code fuck)

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

  • Moderators

I agree with BrewManNH on this, what benefit is there to resurrecting all of these old posts, just so you can promote something you wrote?

"Profanity is the last refuge of the truly ignorant." - Anonymous

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...