Skip to content

Instantly share code, notes, and snippets.

@akaleeroy
Forked from thekingofspain/GotoRegistryEntry.vbs
Last active August 6, 2023 20:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akaleeroy/b6dd73affba0e5adad7c72833121d8d4 to your computer and use it in GitHub Desktop.
Save akaleeroy/b6dd73affba0e5adad7c72833121d8d4 to your computer and use it in GitHub Desktop.
Go to registry entry

Go to registry key

Go to registry key


Opens regedit at your specified location. Copied registry paths will automatically populate the input box (like in the above image).

You may use these formats:

  • HKEY_CURRENT_USER\...
  • HKCU:\...
  • HKCU\...

For convenience create a shortcut to the script: wscript "D:\path\to\GotoRegistryEntry.vbs". Place this next to your other program shortcuts, for example in shell:Start Menu\Programs\Accessories. This way it will show up at the top of the start menu search results, under Programs.

Dim objHTA, cClipboard, WshShell
Set objHTA = createobject("htmlfile")
cClipboard = objHTA.parentwindow.clipboarddata.getdata("text")
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim MyKey
If isRegPath(cClipboard,cClipboard) Then
MyKey = Inputbox("Navigate to this Registry path", "Go to reg key...", cClipboard)
Else
MyKey = Inputbox("Type the Registry path", "Go to reg key...")
End If
If IsEmpty(MyKey) Then
'Cancelled
Else
Call isRegPath(MyKey,MyKey)
MyKey = "Computer\" & MyKey
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey", MyKey, "REG_SZ"
WshShell.Run "regedit.exe -m"
End If
Set objHTA = nothing
Set WshShell = nothing
Function isRegPath(sString,fString)
If IsNull(sString) Then
sString = ""
End If
isRegPath = False
Dim oRegExp, patterns, replacements, item, i, aMatches, match, bFound
patterns = Array("HKEY_", "HKCU:?\\", "HKLM:?\\", "HKU:?\\", "HKCC:?\\", "HKCR:?\\")
replacements = Array("HKEY_", "HKEY_CURRENT_USER\", "HKEY_LOCAL_MACHINE\", "HKEY_USERS\", "HKEY_CURRENT_CONFIG\", "HKEY_CLASSES_ROOT\")
Set oRegExp = New RegExp
oRegExp.IgnoreCase = True
oRegExp.Global = True
Set trailingslash = New RegExp
trailingslash.Pattern = "\\$"
trailingslash.Global = true
i = 0
For Each item In patterns
oRegExp.Pattern = item
Set aMatches = oRegExp.Execute(sString)
bFound = False
For Each match In aMatches
bFound = True
fString = Replace(fString, vbCr, "")
fString = Replace(fString, vbLf, "")
fString = Replace(fString, chr(34), "")
fString = Trim(fString)
fString = trailingslash.Replace(fString, "")
fString = Replace(fString, match, replacements(i))
Exit For
Next
i = i+1
If bFound Then
isRegPath = True
Exit For
Else
isRegPath = False
End If
Next
End Function
@RemixPL1994
Copy link

Hello, should this code still work for Windows 10 PRO x64 bit and build 1903 ??

I try it now and it doesn't work for me in any way. And some time ago I used it and everything was correct.

@akaleeroy
Copy link
Author

@RemixPL1994 Try it manually, maybe the LastKey entry is no longer observed or they moved it somewhere. See L18-L19

@RemixPL1994
Copy link

@akaleeroy

Hello. Are you still available and alive on github?

I thought to go back to the Go to registry key topic and try to update it for the latest windows 10 and 11 to make it work as well.

Let me know what you think if you see this message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment