4

I'm making a small tool that can write a key in registry, and a tiny part of it just for convenience would be to navigate to that key instantly with the click of a button. I know how to open regedit.exe already but is there a way to instantly navigate to the key i need? I'm trying with

System.Diagnostics.Process.Start("regedit.exe" + "c/ HKEY_LOCAL_MACHINE");

but i think it's just trying to write a key into registry.

Thanks in advance!

Edit:

@Arran

-Actually the tool is for myself mainly. I'm still very much a newb at c# or programming in general, and I am learning it on my own. This program is 1/2 a test of what I can do and 1/2 a utility for my later work. My goal with this is to be able to write a key into registry and after that be able to navigate to it and delete it in seconds with out having to manually search through the regedit.

Edit:

@Hans Passant

Thank you for the information! I guess if it's that hard to implement, it's really not worth my time and effort.

WolfyD
  • 865
  • 3
  • 14
  • 29
  • 2
    I would think about the problem in another way. What do you intend to do? Just allow the user to go straight to the key? If you are exporting (backing up) the key, there are better ways to do it. – Arran Jul 03 '13 at 16:32
  • 1
    This is a feature of SysInternals' ProcMon. It uses UI Automation to select the key in Regedit. Nothing particularly simple to do. It is the kind of whiz-bang feature you'd add when you have thousands of users. Look at Project White if you want to burn the time anyway. – Hans Passant Jul 03 '13 at 18:27

1 Answers1

6

This thread is a bit old bit if anyone else ends up here by googling this works.

  1. Set LastKey to your path you want regedit to open in
  2. Launch regedit.

Example:

var registryLocation =  "Your key here";
var registryLastKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit";           
    try
    {
        Registry.SetValue(registryLastKey, "LastKey", registryLocation); // Set LastKey value that regedit will go directly to
        Process.Start("regedit.exe");
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
Niclas Lindgren
  • 542
  • 6
  • 23