How To Open Computer Registry
How do I launch Windows' RegEdit with certain path located, like 'HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio8.0
', so I don't have to do the clicking?
What's the command line argument to do this? Or is there a place to find the explanation of RegEdit's switches?
12 Answers
There's a program called RegJump, by Mark Russinovich, that does just what you want. It'll launch regedit and move it to the key you want from the command line.
RegJump uses (or at least used to) use the same regedit window on each invoke, so if you want multiple regedit sessions open, you'll still have to do things the old fashioned way for all but the one RegJump has adopted. A minor caveat, but one to keep note of, anyway.
Use the following batch file (add to filename.bat
):
to replace:
with your registry path.
From http://windowsxp.mvps.org/jumpreg.htm (I have not tried any of these):
When you start Regedit, it automatically opens the last key that was viewed. (Registry Editor in Windows XP saves the last viewed registry key in a separate location). Dilwale dulhania le jayenge soundtrack. If you wish to jump to a particular registry key directly without navigating the paths manually, you may use any of these methods / tools.
Option 1
Using a VBScript: Copy these lines to a Notepad document as save as registry.vbs
Double-click Registry.vbs and then type the full registry path which you want to open.
Example: HKEY_CLASSES_ROOT.MP3
Limitation: The above method does not help if Regedit is already open.
Note: For Windows 7, you need to replace the line MyKey = 'My Computer' & MyKey
with MyKey = 'Computer' & MyKey
(remove the string My
). For a German Windows XP the string 'My Computer'
must be replaced by 'Arbeitsplatz'
.
Option 2
Regjump from Sysinternals.com
This little command-line applet takes a registry path and makes Regedit open to that path. It accepts root keys in standard (e.g. HKEY_LOCAL_MACHINE) and abbreviated form (e.g. HKLM).
Usage: regjump [path]
Example: C:Regjump HKEY_CLASSES_ROOT.mp3
Option 3
12Ghosts JumpReg from 12ghosts.com
Jump to registry keys from a tray icon! This is a surprisingly useful tool. You can manage and directly jump to frequently accessed registry keys. Unlimited list size, jump to keys and values, get current key with one click, jump to key in clipboard, jump to same in key in HKCU or HKLM. Manage and sort keys with comments in an easy-to-use tray icon menu. Create shortcuts for registry keys.
I'd also like to note that you can view and edit the registry from within PowerShell. Launch it, and use set-location to open the registry location of your choice. The short name of an HKEY is used like a drive letter in the file system (so to go to HKEY_LOCAL_MACHINESoftware, you'd say: set-location hklm:Software).
More details about managing the registry in PowerShell can be found by typing get-help Registry at the PowerShell command prompt.
Here is one more batch file solution with several enhancements in comparison to the other batch solutions posted here.
It also sets string value LastKey
updated by Regedit itself on every exit to show after start the same key as on last exit.
The enhancements are:
Registry path can be passed also as command line parameter to the batch script.
Registry path can be entered or pasted with or without surrounding double quotes.
Registry path can be entered or pasted or passed as parameter with or without surrounding square brackets.
Registry path can be entered or pasted or passed as parameter also with an abbreviated hive name (HKCC, HKCU, HKCR, HKLM, HKU).
Batch script checks for already running Regedit as registry key is not shown when starting Regedit while Regedit is running already. The batch user is asked if running instance should be killed to restart it for showing entered registry path. If the batch user chooses not to kill Regedit, Regedit is started without setting entered path resulting (usually) in just getting Regedit window to foreground.
The batch file tries to automatically get name of registry root which is on English Windows XP My Computer, on German Windows XP, Arbeitsplatz, and on Windows 7 just Computer. This could fail if the value
LastKey
of Regedit is missing or empty in registry. For this case please set the right root name in third line of the batch code.
Copy the below text and save it as a batch file and run
Input the path of the registry key you wish to open when the batch file prompts for it, and press Enter. Regedit opens to the key defined in that value.
I thought this C# solution might help:
By making use of an earlier suggestion, we can trick RegEdit into opening the key we want even though we can't pass the key as a parameter.
In this example, a menu option of 'Registry Settings' opens RegEdit to the node for the program that called it.
Program's form:
MyCommonFunctions.Registry
Of course, you could put it all in one method of the form, but I like reusablity.
Create a BAT file using clipboard.exe and regjump.exeto jump to the key in the clipboard:
( %~dp0 means 'the path to the BAT file' )
Building on lionkingrafiki's answer, here's a more robust solution that will accept a reg key path as an argument and will automatically translate HKLM to HKEY_LOCAL_MACHINE or similar as needed. If no argument, the script checks the clipboard using the htmlfile
COM object invoked by a JScript hybrid chimera. The copied data will be split and tokenized, so it doesn't matter if it's not trimmed or even among an entire paragraph of copied dirt. And finally, the key's existence is verified before LastKey
is modified. Key paths containing spaces must be within double quotes.
Here is a simple PowerShell function based off of this answer above https://stackoverflow.com/a/12516008/1179573
The answer above doesn't actually explain very well what it does. When you close RegEdit, it saves your last known position in HKCU:SoftwareMicrosoftWindowsCurrentVersionAppletsRegedit
, so this merely replaces the last known position with where you want to jump, then opens it.
This seems horribly out of date, but Registration Info Editor (REGEDIT) Command-Line Switches claims that it doesn't support this.
You can make it appear like regedit does this behaviour by creating a batch file (from the submissions already given) but call it regedit.bat and put it in the C:WINDOWSsystem32 folder. (you may want it to skip editting the lastkey in the registry if no command line args are given, so 'regedit' on its own works as regedit always did) Then 'regedit HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio8.0' will do what you want.
This uses the fact that the order in PATH is usually C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem; etc