Jump to content

How to jump to the desired registry key with one click


Recommended Posts

Posted

The second cool thing I have found off this blog that I think needs reposting :)

 

How to jump to the desired registry key with one click | Winaero

 

Since Windows 2000, the Registry Editor is able to remember the last opened key before you closed it. This data is stored at the following registry key:

 

HKEY_Current_User\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit

The LastKey value is used by Windows to store the last used key.

 

 

 

As you can see, this is a per-user registry branch, so Windows stores the last used key for every user separately. It is possible to utilize this feature to directly jump to the key you need. Let me show how it can be done via Windows Scripting Host and VBScript.

 

The Implementation

 

The idea is to copy the full path of the desired registry key to the clipboard and replace the LastKey value with the copied value from the clipboard. When regedit.exe is started after doing this, it will open directly at the key you want.

 

How to fetch clipboard content with VBscript

 

The "htmlfile" ActiveX object is used to display HTML help and HTA files in Windows. It can be used to fetch clipboard content. It does not even require IE to be installed . The code is as follows:

 

set objHTA=createobject("htmlfile")

cClipBoard=objHTA.parentwindow.clipboarddata.getdata("text")

 

If clipboard content is text, it will be stored in cClipBoard variable. Simple, isn't it?

 

Directly opening Regedit at desired key

 

Since we now have the desired key in cClipboard, we have to write it into LastKey value metioned above. The code for that is:

 

Dim WshShell

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey", сClipBoard, "REG_SZ"

 

This code snippet is self-explanatory, so there is no need to comment it.

 

The final script looks like this:

 

Dim objHTA

Dim cClipBoard

Dim WshShell

set objHTA=createobject("htmlfile")

cClipBoard=objHTA.parentwindow.clipboarddata.getdata("text")

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey", cClipBoard, "REG_SZ"

WshShell.Run "regedit.exe -m"

Set objHTA = nothing

Set WshShell = nothing

 

Note that WshShell.Run "regedit.exe -m" line. It contains the undocumented "-m" switch, which allows you to run multiple instances of Regedit simultaneously.

 

I have saved this script as "RegNav.vbs" file and you can download it right now:

 

Download ready to use VB Script

 

If opening Regedit is a very frequent task for you, then you can pin regnav.vbs to the taskbar. Create a new shortcut and type the following into the shortcut target text box:

 

wscript.exe d:\regnav.vbs

Don't forget to use the correct path to regnav.vbs.

 

Now right click on the shortcut file you have created and click "Pin to Taskbar" from the context menu. That's all.

 

P.S. How to test this script

 

Select this text

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

Press CTRL+C

Click on regnav.vbs.

  • Thanks 1
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...