Curious if anyone has an example or demo of treeview for browsing the registry.
Been using PowerShell Studio 2017 since January and cannot say enough good things about it. I've created some useful tools for my users and learned a bit along the way. Been perusing the forums and blogs since then with great success. That said, I've run into a small road-block with this one. I'd love to be able open a child window on my tech tool and browse to a select a reg key and/or value. I am currently using a combo box for HKLM/HKCU and then just a paste of the key/value.
Found some C# code that resembles what I'm looking for (I think) but no PowerShell GUI code.
Can't post a link since this is my first post. From the MSDN forum --> "treeview like RegEdit".
Any assistance or direction is greatly appreciated!
Registry TreeView
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Registry TreeView
Thanks for the reply. I'll play around with it some more. It's a pretty complex control - was hoping someone may have already built a registry browse function with treeview. Therefore, I could learn by example.
Re: Registry TreeView
Here is an example of how to use the TreeView. Click a node to expand. Look at the code to see how the magic is accomplished.
The second file is a more complex example of how to handle complex objects in a TreeView.
Don't forget to read the articles in the Info Center.
The second file is a more complex example of how to handle complex objects in a TreeView.
Don't forget to read the articles in the Info Center.
- Attachments
-
- Demo-TreeviewFromPath.psf
- (41.92 KiB) Downloaded 210 times
-
- Demo-TreeviewFolders.psf
- (23.55 KiB) Downloaded 193 times
Re: Registry TreeView
Much appreciated. I'll check them out. Been over the blogs a couple times but it's going to take some more reading for them to sink in.
Re: Registry TreeView
Not much luck on this I'm afraid. Your examples, those from the Info Center, and others are helpful but I think this one might be out of my league for the time being. I've had really good success up until today. Maybe I can circle back in a month or two and see if anything jives then.
Short of manually adding a list to treeview, this is only way I've been able to successfully auto-populate a list. Couldn't do much past this, however.
Short of manually adding a list to treeview, this is only way I've been able to successfully auto-populate a list. Couldn't do much past this, however.
- $keys = Get-ChildItem -Path Registry::HKEY_LOCAL_MACHINE\software
- foreach ($key in $keys.name)
- {
- $treeview1.Nodes.Add($key)
- }
Re: Registry TreeView
Couldn't sleep this morning and decided to take another stab. I think I'm well on the way to success now. I tried using a registry method (like was presented in the Explorer example) but quickly got confused. Instead, I went back to your suggestion of Get-ChildItem. The code below is doing basically what I would like. Now I just need to clean it up and plug it in where it's needed.
I forgot to add the event NodeMouseClick and when I tried this in a new form. That was frustrating to say the least.
Thanks for the guidance!
I forgot to add the event NodeMouseClick and when I tried this in a new form. That was frustrating to say the least.
- $form1_Load = {
- $keys = Get-ChildItem -Path Registry::HKEY_LOCAL_MACHINE
- foreach ($key in $keys.name)
- {
- $treeview1.Nodes.Add($key)
- }
- }
- $treeview1_NodeMouseClick = [System.Windows.Forms.TreeNodeMouseClickEventHandler]{
- $node = $_.Node.Text
- Try
- {
- if ($_.Node.Nodes.Count -eq 0)
- {
- $keys = Get-ChildItem -Path Registry::$node -ErrorAction SilentlyContinue
- foreach ($key in $keys.name)
- {
- $_.Node.Nodes.Add($key)
- }
- }
- }
- Catch { }
- }
Re: Registry TreeView
Here is a demo of how to easily use the registry with TreeView. It is rough but is man example of how to use the object capabilities along with the tree. This simplifies navigation.
- Attachments
-
- Demo-TreeviewRegistry.psf
- (23.93 KiB) Downloaded 242 times
Re: Registry TreeView
So much cleaner than what I came up with (looks for the like button). The selectable value data on the right is great. I'm all set now!