Results 1 to 12 of 12

Thread: Open specified path in registry

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2011
    Posts
    137

    Open specified path in registry

    Hello,
    I want to open the specified location in Registry using VB.NET similar
    Registry Favorite, how to do?

    The regedit.exe can not open specified location.

    Here the code i tried.

    Code:
    Dim rKey As RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products", True)
    Process.Start("regedit.exe")
    Thank you

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Open specified path in registry

    Process.Start("regedit.exe")
    Well clearly that won't do because there is no command line argument to direct it. Unfortunately however, no such command line argument exists so you cannot open regedit to a specific key in this way. You could automate adding a new favourite and/or the choice of an existing favourite (though I'm far from convinced it's worth the effort).
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Open specified path in registry

    Your code does two things.

    1. Gives your application access to a RegistryKey (see here)
    2. Opens a program

    These are 2 seperate things that have nothing in relation to each other. Are you trying to "jump" to that location using the Regedit application?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2011
    Posts
    137

    Re: Open specified path in registry

    I need the code from my code.
    I want to open a registry key from the path
    After entering the code to textbox using a full of registry key and jump to key in a registry.

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Open specified path in registry

    Quote Originally Posted by dunfiddlin View Post
    You could automate adding a new favourite and/or the choice of an existing favourite (though I'm far from convinced it's worth the effort).
    This is the crux of the matter right here. The effort required would hardly be worth it. Why do you want to do this ? Perhaps the problem this is meant to solve has a much less painful solution.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Open specified path in registry

    Am i right in thinking you want to "Jump" to a key when regedit opens? I know there is a favorite menu but what about setting the LasyKey.
    Last edited by ident; Aug 29th, 2013 at 04:04 PM. Reason: Not needed extra
    My Github - 1d3nt

  7. #7
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Open specified path in registry

    @ident: Great minds... I was just playing with that.

    Tested on Windows 7. No idea about anything else.

    Have to make sure RegEdit.exe isn't already running , or it doesn't seem to work. And leaving a trailing "\" on the target key path seems to stop the key's contents from displaying. (possibly doesn't bode well, lol)

    Code:
    Imports Microsoft.Win32
    
    Private Sub Button1_Click(sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
        DisplayRegKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer")
    
    End Sub
    
    Private Sub DisplayRegKey(regKeyToDisplay As String)
    
        regKeyToDisplay.TrimEnd("\"c)
    
        Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit", "LastKey", regKeyToDisplay, RegistryValueKind.String)
    
        '   RegEdit.exe not to be running already
        For Each p As Process In Process.GetProcessesByName("regedit")
            p.Kill()
        Next
    
        Process.Start("regedit.exe")
    
    End Sub

  8. #8
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Open specified path in registry

    Works fine on XP Inferrd, Good job.
    My Github - 1d3nt

  9. #9
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Open specified path in registry

    Interesting approach. That's pretty clever.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jun 2011
    Posts
    137

    Re: Open specified path in registry

    Awesome

    Thanks for your help.

  11. #11
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Open specified path in registry

    Funky!

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jun 2011
    Posts
    137

    Re: Open specified path in registry

    work fine on all windows great work buddy thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width