How to launch Windows' RegEdit with certain path?

前端 未结 13 1032
盖世英雄少女心
盖世英雄少女心 2020-12-08 04:15

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 clic

相关标签:
13条回答
  • 2020-12-08 04:31

    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

    0 讨论(0)
  • 2020-12-08 04:33

    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.

    0 讨论(0)
  • 2020-12-08 04:34

    Copy the below text and save it as a batch file and run

    @ECHO OFF
    SET /P "showkey=Please enter the path of the registry key: "
    REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit" /v "LastKey" /d "%showkey%" /f
    start "" regedit
    

    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.

    0 讨论(0)
  • 2020-12-08 04:35

    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.

    0 讨论(0)
  • 2020-12-08 04:38

    Use the following batch file (add to filename.bat):

    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit /v LastKey /t REG_SZ /d Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Veritas\NetBackup\CurrentVersion\Config /f
    START regedit
    

    to replace:

    Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Veritas\NetBackup\CurrentVersion\Config
    

    with your registry path.

    0 讨论(0)
  • 2020-12-08 04:39

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

    0 讨论(0)
提交回复
热议问题