How to launch Windows' RegEdit with certain pa

2020-02-02 08:35发布

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?

12条回答
乱世女痞
2楼-- · 2020-02-02 09:14

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:\WINDOWS\system32 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_USER\Software\Microsoft\VisualStudio\8.0" will do what you want.

This uses the fact that the order in PATH is usually C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem; etc

查看更多
ら.Afraid
3楼-- · 2020-02-02 09:15

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). 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

'Launches Registry Editor with the chosen branch open automatically
'Author  : Ramesh Srinivasan
'Website: http://windowsxp.mvps.org

Set WshShell = CreateObject("WScript.Shell")
Dim MyKey
MyKey = Inputbox("Type the Registry path")
MyKey = "My Computer\" & MyKey
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Lastkey",MyKey,"REG_SZ"
WshShell.Run "regedit", 1,True
Set WshShell = Nothing

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.

查看更多
欢心
4楼-- · 2020-02-02 09:19

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_MACHINE\Software, 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.

查看更多
欢心
5楼-- · 2020-02-02 09:20

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:

    private void registrySettingsToolStripMenuItem_Click(object sender, EventArgs e)
    {
        string path = string.Format(@"Computer\HKEY_CURRENT_USER\Software\{0}\{1}\",
                                    Application.CompanyName, Application.ProductName);

        MyCommonFunctions.Registry.OpenToKey(path);

    }

MyCommonFunctions.Registry

    /// <summary>Opens RegEdit to the provided key
    /// <para><example>@"Computer\HKEY_CURRENT_USER\Software\MyCompanyName\MyProgramName\"</example></para>
    /// </summary>
    /// <param name="FullKeyPath"></param>
    public static void OpenToKey(string FullKeyPath)
    {
        RegistryKey rKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Applets\Regedit", true);
        rKey.SetValue("LastKey",FullKeyPath);

        Process.Start("regedit.exe");
    }

Of course, you could put it all in one method of the form, but I like reusablity.

查看更多
Viruses.
6楼-- · 2020-02-02 09:21

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.

查看更多
淡お忘
7楼-- · 2020-02-02 09:25

Create a BAT file using clipboard.exe and regjump.exe to jump to the key in the clipboard:

clipboard.exe > "%~dp0clipdata.txt"
set /p clipdata=input < "%~dp0clipdata.txt"
regjump.exe %clipdata%

( %~dp0 means "the path to the BAT file" )

查看更多
登录 后发表回答