Use PowerShell to open regedit at a specific path or RegJump for PowerShell

Even though PowerShell contains everything to read and write to the registry I still find myself quite frequently opening the registry editor (aka regedit.exe). Since navigating the tree manually can be quite time consuming I used to rely on RegJump developed by Mark Russinovich.
I was wondering if the same could be implemented using PowerShell and maybe even adding some features like opening multiple registry keys either from the clipboard or provided as an argument to the function.
Say hello to Open-Registry alias regJump. The function opens (instances of) the registry editor for provided paths from the clipboard or as argument to the regKey parameter. The registry paths can contain hive name shortnames like HKLM, HKCU, HKCR or PowerShell provider paths syntax like HKLM:\, HKCU:\.
Similar to how RegJump.exe handles non-existing paths Open-Registry also ignores those parts of the path and works its way backwards until it finds a valid path or returns an error message if the path doesn’t contain any valid parts.
Let’s look at some example use cases:

  1. Opening multiple instances of regedit at the specified paths via an argument to the regKey paramater:
    $testKeys =@'
    HKLM\Software\Microsoft\Outlook Express
    '@ -split "`r`n"
    Open-Registry $testKeys
  2. Same as above but the keys are no copied to the clipboard instead:
    HKLM\Software\Microsoft\Outlook Express
    '@ -split "`r`n" | clip
  3. The example will open regedit with the run key open as the last part of the path does not represent a key
    Open-Registry HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Skype
  4. The example provides an invalid path to the function (using the alias) resulting in a warning message and no instance of regedit opening
    regJump HKLMm\xxxxx

Further down below is the source code for the function without comment based help in order to reduce its screen size but the full version can be download from GitHub.
As usual when writing PowerShell I’ve learned one or the other thing along the way. This time I learned how to start a process and wait until its window is visible (this was necessary since otherwise regedit would launch all instances opened on the last path (when multiple paths were passed to the function)):


Photo Credit: eLKayPics _ off via Compfight cc


I'd love to hear what you think

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s