如何使用某个路径启动Windows RegEdit ,例如“<代码> HKEY_CURRENT_USER \ Software \ Microsoft \ VisualStudio \ 8.0 &quot;,所以我不必点击?

执行此操作的命令行参数是什么?或者有没有地方可以找到RegEdit开关的解释?

有帮助吗?

解决方案

Mark Russinovich有一个名为 RegJump 的程序正是你想要的。它将启动regedit并将其从命令行移动到您想要的密钥。

RegJump在每次调用时都使用(或者至少使用过)相同的regedit窗口,所以如果你想打开多个regedit会话,你仍然需要以老式的方式做所有事情,但RegJump采用了一个。无论如何,这是一个小小的警告,但要注意一点。

其他提示

使用以下批处理文件(添加到 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

替换:

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

使用您的注册表路径。

来自 http://windowsxp.mvps.org/jumpreg.htm (我有没试过这些):

启动Regedit时,它会自动打开查看的最后一个键。 (Windows XP中的注册表编辑器将最后查看的注册表项保存在单独的位置)。如果您希望直接跳转到特定的注册表项而不手动导航路径,则可以使用这些方法/工具中的任何一种。

选项1
使用VBScript:将这些行复制到记事本文档,另存为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

双击Registry.vbs,然后键入要打开的完整注册表路径。

示例: HKEY_CLASSES_ROOT \ .MP3

限制:如果Regedit已经打开,则上述方法无效。

注意:对于Windows 7,您需要替换 MyKey =&quot; My Computer \“行。 &安培; MyKey with MyKey =&quot; Computer \&quot; &安培; MyKey (删除字符串 My )。对于德语Windows XP,字符串&quot; My Computer \“必须替换为&quot; Arbeitsplatz \&quot;

选项2
来自Sysinternals.com的Regjump

这个小命令行小程序采用注册表路径并使Regedit对该路径开放。它接受标准(例如HKEY_LOCAL_MACHINE)和缩写形式(例如HKLM)中的根密钥。

用法:regjump [路径]

示例: C:\ Regjump HKEY_CLASSES_ROOT \ .mp3

选项3
来自12ghosts.com的12Ghosts JumpReg

从托盘图标跳转到注册表项!这是一个非常有用的工具。您可以管理并直接跳转到经常访问的注册表项。无限的列表大小,跳转到键和值,一键获取当前键,跳转到剪贴板中的键,跳转到HKCU或HKLM中的键。在易于使用的托盘图标菜单中使用注释管理和排序键。创建注册表项的快捷方式。

我还要注意,您可以在PowerShell中查看和编辑注册表。启动它,并使用set-location打开您选择的注册表位置。 HKEY的短名称就像文件系统中的驱动器号一样使用(所以要转到HKEY_LOCAL_MACHINE \ Software,你会说:set-location hklm:\ Software)。

通过在PowerShell命令提示符下键入get-help Registry,可以找到有关在PowerShell中管理注册表的更多详细信息。

这是另一个批处理文件解决方案,与此处发布的其他批处理解决方案相比,具有多项增强功能。

它还设置字符串值 LastKey ,在每个退出时由Regedit更新,以便在启动与上次退出时相同的键后显示。

@echo off
setlocal EnableDelayedExpansion
set "RootName=Computer"

if not "%~1"=="" (
    set "RegKey=%~1"
    goto PrepareKey
)

echo/
echo Please enter the path of the registry key to open.
echo/
set "RegKey="
set /P "RegKey=Key path: "

rem Exit batch file without starting Regedit if nothing entered by user.
if "!RegKey!"=="" goto ExitBatch

:PrepareKey
rem Remove square brackets and double quotes from entered key path.
set "RegKey=!RegKey:"=!"
if "!RegKey!"=="" goto ExitBatch
set "RegKey=!RegKey:[=!"
if "!RegKey!"=="" goto ExitBatch
set "RegKey=!RegKey:]=!"
if "!RegKey!"=="" goto ExitBatch

rem Replace hive name abbreviation by appropriate long name.
set "Abbreviation=%RegKey:~0,4%"
if /I "%Abbreviation%"=="HKCC" (
    set "RegKey=HKEY_CURRENT_CONFIG%RegKey:~4%"
    goto GetRootName
)
if /I "%Abbreviation%"=="HKCR" (
    set "RegKey=HKEY_CLASSES_ROOT%RegKey:~4%"
    goto GetRootName
)
if /I "%Abbreviation%"=="HKCU" (
    set "RegKey=HKEY_CURRENT_USER%RegKey:~4%"
    goto GetRootName
)
if /I "%Abbreviation%"=="HKLM" (
    set "RegKey=HKEY_LOCAL_MACHINE%RegKey:~4%"
    goto GetRootName
)
if /I "%RegKey:~0,3%"=="HKU" (
    set "RegKey=HKEY_USERS%RegKey:~3%"
)

:GetRootName
rem Try to determine automatically name of registry root.
for /F "tokens=1,2*" %%K in ('%SystemRoot%\System32\reg.exe query "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit" /v "LastKey"') do (
    if /I "%%K"=="LastKey" (
        for /F "delims=\" %%N in ("%%M") do set "RootName=%%N"
    )
)

rem Is Regedit already running?
%SystemRoot%\System32\tasklist.exe | %SystemRoot%\System32\findstr.exe /B /I /L regedit.exe >nul
if errorlevel 1 goto SetRegPath

echo/
echo Regedit is already running. Path can be set only when Regedit is not running.
echo/
set "Choice=N"
set /P "Choice=Kill Regedit (y/N): "
if /I "!Choice!"=="y" (
    %SystemRoot%\System32\taskkill.exe /IM regedit.exe >nul 2>nul
    goto SetRegPath
)
echo Switch to running instance of Regedit without setting entered path.
goto StartRegedit

:SetRegPath
rem Add this key as last key to registry for Regedit.
%SystemRoot%\System32\reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit" /v "LastKey" /d "%RootName%\%RegKey%" /f >nul 2>nul

:StartRegedit
start /B regedit.exe

:ExitBatch
endlocal

增强功能包括:

  1. 注册表路径也可以作为命令行参数传递给批处理脚本。

  2. 可以输入或粘贴注册表路径,包含或不包含双引号。

  3. 注册表路径可以作为参数输入或粘贴或传递,包括或不包含方括号。

  4. 注册表路径可以输入或粘贴或作为参数传递,也可以使用缩写的蜂巢名称(HKCC,HKCU,HKCR,HKLM,HKU)。

  5. 在Regedit已经运行时启动Regedit时,未显示批处理脚本检查已经运行的Regedit作为注册表项。将询问批处理用户是否应该终止正在运行的实例以重新启动它以显示输入的注册表路径。如果批处理用户选择不杀死Regedit,则启动Regedit时不会设置输入路径(通常),只需将Regedit窗口置于前台。

  6. 批处理文件尝试自动获取英语Windows XP 我的电脑,德语Windows XP, Arbeitsplatz 和Windows上的注册表根名称7只是计算机。如果Regedit的值 LastKey 在注册表中丢失或为空,则可能会失败。对于这种情况,请在批次代码的第三行设置正确的根名称。

复制以下文本并将其另存为批处理文件并运行

@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

输入批处理文件提示时要打开的注册表项的路径,然后按 Enter 。 Regedit将打开该值中定义的键。

我认为这个C#解决方案可能有所帮助:

通过使用早先的建议,即使我们无法将密钥作为参数传递,我们也可以欺骗RegEdit打开我们想要的密钥。

在此示例中,“注册表设置”的菜单选项包括“注册表设置”。将RegEdit打开到调用它的程序的节点。

计划表格:

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

当然,您可以将其全部放在表单的一个方法中,但我喜欢reusablity。

使用clipboard.exe和regjump.exe创建BAT文件 跳转到剪贴板中的键:

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

(%~dp0表示“BAT文件的路径”)

lionkingrafiki的回答的基础上,这是一个更强大的解决方案,它将接受一个注册密钥路径作为参数,并将自动根据需要将HKLM翻译成HKEY_LOCAL_MACHINE或类似名称。如果没有参数,脚本将使用 JScript混合嵌合体 htmlfile COM对象检查剪贴板>。复制的数据将被拆分和标记化,因此无论是否修剪,甚至是整段复制的污垢都无关紧要。最后,在修改 LastKey 之前验证密钥的存在。包含空格的关键路径必须在双引号内。

@if (@CodeSection == @Batch) @then
:: regjump.bat
@echo off & setlocal & goto main

:usage
echo Usage:
echo   * %~nx0 regkey
echo   * %~nx0 with no args will search the clipboard for a reg key
goto :EOF

:main
rem // ensure variables are unset
for %%I in (hive query regpath) do set "%%I="

rem // if argument, try navigating to argument.  Else find key in clipboard.
if not "%~1"=="" (set "query=%~1") else (
    for /f "delims=" %%I in ('cscript /nologo /e:JScript "%~f0"') do (
        set "query=%%~I"
    )
)

if not defined query (
    echo No registry key was found in the clipboard.
    goto usage
)

rem // convert HKLM to HKEY_LOCAL_MACHINE, etc. while checking key exists
for /f "delims=\" %%I in ('reg query "%query%" 2^>NUL') do (
    set "hive=%%~I" & goto next
)

:next
if not defined hive (
    echo %query% not found in the registry
    goto usage
)

rem // normalize query, expanding HKLM, HKCU, etc.
for /f "tokens=1* delims=\" %%I in ("%query%") do set "regpath=%hive%\%%~J"
if "%regpath:~-1%"=="\" set "regpath=%regpath:~0,-1%"

rem // https://stackoverflow.com/a/22697203/1683264
>NUL 2>NUL (
    REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit"^
        /v "LastKey" /d "%regpath%" /f
)

echo %regpath%

start "" regedit
goto :EOF

@end // begin JScript hybrid chimera
// https://stackoverflow.com/a/15747067/1683264
var clip = WSH.CreateObject('htmlfile').parentWindow.clipboardData.getData('text');

clip.replace(/"[^"]+"|\S+/g, function(<*>) {
    if (/^\"?(HK[CLU]|HKEY_)/i.test(<*>)) {
        WSH.Echo(<*>);
        WSH.Quit(0);
    }
});

您可以通过创建批处理文件(来自已提交的提交)使其显示为regedit,但将其命名为regedit.bat并将其放在C:\ WINDOWS \ system32文件夹中。 (如果没有给出命令行参数,你可能希望它跳过编辑注册表中的lastkey,所以“regedit”本身就像regedit一样工作)然后“regedit HKEY_CURRENT_USER \ Software \ Microsoft \ VisualStudio \ 8.0”会做你想做的事。

这使用PATH中的顺序通常是C:\ WINDOWS \ system32; C:\ WINDOWS; C:\ WINDOWS \ System32 \ Wbem;等

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top