Windows 10 – Open Reg Key at Specific Location

email me

@echo off
:: check for input
if %1==”” exit /b 1
set REGKEY=%1

:: set reg key
REG ADD “HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit” /v “LastKey” /d “%REGKEY%” /f

:: open registry editor
taskkill /f /im regedit.exe

start “” regedit.exe

 

Command

OpenLastKey.cmd HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion

 

Output

 

Notes

AutoHotKey Submitted by Rick Corbett

#j::
{
LK_loc = HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit ; Location of LastKey entry

ClipSaved := ClipboardAll ; Save the current clipboard contents

Clipboard = ; Empty the clipboard

SendInput, ^c ; Copy selected registry key to the clipboard

ClipWait ; Wait for the clipboard to contain text

; Search and replace any abbreviations
StringReplace, Clipboard, Clipboard, HKCR, HKEY_CLASSES_ROOT
StringReplace, Clipboard, Clipboard, HKCC, HKEY_CURRENT_CONFIG
StringReplace, Clipboard, Clipboard, HKCU, HKEY_CURRENT_USER
StringReplace, Clipboard, Clipboard, HKLM, HKEY_LOCAL_MACHINE
StringReplace, Clipboard, Clipboard, HKU, HKEY_USERS

RegWrite, REG_SZ, %LK_loc%, LastKey, %Clipboard% ; Write LastKey data from clipboard to registry as a string

Clipboard = ; Empty the clipboard

Clipboard := ClipSaved ; Restore the original clipboard contents

Run, %windir%\regedit.exe ; Open the Registry Editor

Return
}