How do I launch Windows' RegEdit with certain path located, like "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.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?
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 beforeLastKey
is modified. Key paths containing spaces must be within double quotes.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.This seems horribly out of date, but Registration Info Editor (REGEDIT) Command-Line Switches claims that it doesn't support this.
Use the following batch file (add to
filename.bat
):to replace:
with your registry path.
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.
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:\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit
, so this merely replaces the last known position with where you want to jump, then opens it.