Navigating The Registry

C

Chuck

If I'm reading thru Microsoft (or other) documents, and find a registry
reference, such as in the example, what's the fastest way of examining that
entry in my registry?

The only way I know is to:
1) Start Regedit.
2) Open HKLM.
3) Open System.
4) Open CurrentControlSet.
5) Open Services.
6) Open Netbt.
7) Open Parameters.

What a pain in the ass. Anybody know of a utility that lets me copy and paste
(or dream on - right click??) a key such as
"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Netbt\Parameters\", and
open the registry key easily?

### Start Example

RESOLUTION
WARNING: If you use Registry Editor incorrectly, you may cause serious problems
that may require you to reinstall your operating system. Microsoft cannot
guarantee that you can solve problems that result from using Registry Editor
incorrectly. Use Registry Editor at your own risk.

To resolve this issue, use Registry Editor (Regedit.exe) to locate the following
key in the registry:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Netbt\Parameters\
Change the value of the EnableProxy value in the preceding registry key to 0 or
1, quit Registry Editor, and then restart your computer.

### End Example
 
R

Ramesh, MS-MVP

Without third-party tools, use a VBScript.

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

Copy the above lines to Notepad and save as "registry.vbs". Double-click
registry.vbs, type the full registry path in the Input box (Example:
HKEY_CURRENT_CONFIG\System ). Regedit will open with the key chosen.

Limitation: This does not help if Regedit is already open.
 
T

Terry

On 2/1/2005 11:00 AM On a whim, Ramesh, MS-MVP pounded out on the keyboard
Without third-party tools, use a VBScript.

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

Copy the above lines to Notepad and save as "registry.vbs". Double-click
registry.vbs, type the full registry path in the Input box (Example:
HKEY_CURRENT_CONFIG\System ). Regedit will open with the key chosen.

Limitation: This does not help if Regedit is already open.

I just tried the script and it gave an error message:
Script: registry.vbs
Line: 6
Char: 1
Error: Expected statement
Code: 800A0400
Source: Microsoft VBScript compilation error

Cool idea if it works!

--
Terry

***Reply Note***
Anti-spam measures are included in my email address.
Delete NOSPAM from the email address after clicking Reply.
 
T

Terry

Line 5 was broken. Thank you.

--
Terry

***Reply Note***
Anti-spam measures are included in my email address.
Delete NOSPAM from the email address after clicking Reply.


On 2/1/2005 6:42 PM On a whim, David Candy pounded out on the keyboard
It is a 6 line script. Not 7 as I suspect you've entered.
WshShell.RegWrite is the beginning of a long line.

You may want to look at www.mvps.org/serenitymacros/win98.html
But it will add a entry to the New sub menu for a New Registry Shortcut wizard.
Create Shortcuts to Windows Registry Keys
RegShortcut provides shortcuts to keys or values in the registry. It can be used as a command line utility or by right clicking in a explorer window (or desktop) and choosing New - Registry Shortcut.

Syntax
RegShortcut /? | RegPath | /Unreg | /New

/? Displays help
RegPath The registry key or value to open in Regedit
/Unreg Removes RegShortcut's registry entries
/New Runs Creates New Registry Shortcut Wizard

Notes
a.. RegShortcut works by pretending to press keys. This means that if a user is working on the computer and clicks away from Microsoft's Regedit as it starts then the current application will recieve the key strokes. RegShortcut takes some precautions to guard against this but is not bullet proof.
b.. This is a Visual Basic 6 application. The run time library is not included. Download from ftp://ftp.microsoft.com/Softlib/MSLFILES/vbrun60.exe. To tell if you need to download this file check to see if Msvbvm60.dll is in your Windows\System folder. If it is then the run time libraries are already installed.
c.. RegShortcut registers itself in the registry each time it's run. Therefore to install the file just copy it to any folder and double click the file. Thereafter it will run just by typing it's name. It can be renamed or moved, just start the program and it will register the new name or location.
d.. The Registry key must exist. Keys end with a trailing backslash. Values do not end with a trailing backslash.
e.. If Regedit is already opened, the selection must be in the left hand pane (the tree pane) for the correct key to open.
Download RegShortcut.zip (15K) includes source files

Anyway, to improve Ramesh's script (and to make it work with the next tip) (note the second last line is still very long and unchanged). This means it works with arguments

RameshScript.vbs "HKCU\Somewhere"

Set WshShell = CreateObject("WScript.Shell")
Set Ag = WScript.Arguments
MyKey = "My Computer\" & Ag(0)
WshShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Lastkey",MyKey,"REG_SZ"
WshShell.Run "regedit", 1,True

We can now generate a protocol handler
Windows Registry Editor Version 5.00

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\reg]
@="URL:Registry"
"EditFlags"=dword:00000002
"URL Protocol"=""

[HKEY_CLASSES_ROOT\reg\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,75,00,72,00,\
6c,00,2e,00,64,00,6c,00,6c,00,2c,00,30,00,00,00


[HKEY_CLASSES_ROOT\reg\shell\open\command]
@="wscript \"c:\\OpenRegKey.vbs\" %1"

So typing in Start Run

Reg://HKEY_CLASSES_ROOT\reg\shell\open\command

will open the registry key. You need to fix the reg file (eg it's using the ftp icon) and as the reg:// gets passed as well one needs to strip reg:// of the beginning of the string.

So Ramesh's script becomes

Set WshShell = CreateObject("WScript.Shell")
Set Ag = WScript.Arguments
MyKey = Mid(Ag(0),7)
MyKey = "My Computer\" & MyKey
WshShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Lastkey",MyKey,"REG_SZ"
WshShell.Run "regedit", 1,True

I've attached a copy of final script and reg file.
 
R

Ramesh, MS-MVP

Hi David,

Brilliant ideas, both. I never thought of using SendKeys method. BTW, the
two other programs seem to use an undocumented API.

--
Ramesh, Microsoft MVP
Windows XP Shell/User
http://windowsxp.mvps.org


"David Candy" <.> wrote in message
It is a 6 line script. Not 7 as I suspect you've entered.
WshShell.RegWrite is the beginning of a long line.

You may want to look at www.mvps.org/serenitymacros/win98.html
But it will add a entry to the New sub menu for a New Registry Shortcut
wizard.
Create Shortcuts to Windows Registry Keys
RegShortcut provides shortcuts to keys or values in the registry. It can be
used as a command line utility or by right clicking in a explorer window (or
desktop) and choosing New - Registry Shortcut.
 
R

Ramesh, MS-MVP

You're welcome.

--
Ramesh, Microsoft MVP
Windows XP Shell/User
http://windowsxp.mvps.org


Terry said:
Line 5 was broken. Thank you.

--
Terry

***Reply Note***
Anti-spam measures are included in my email address.
Delete NOSPAM from the email address after clicking Reply.


On 2/1/2005 6:42 PM On a whim, David Candy pounded out on the keyboard
It is a 6 line script. Not 7 as I suspect you've entered.
WshShell.RegWrite is the beginning of a long line.

You may want to look at www.mvps.org/serenitymacros/win98.html
But it will add a entry to the New sub menu for a New Registry Shortcut
wizard.
Create Shortcuts to Windows Registry Keys RegShortcut provides shortcuts
to keys or values in the registry. It can be used as a command line
utility or by right clicking in a explorer window (or desktop) and
choosing New - Registry Shortcut.

Syntax
RegShortcut /? | RegPath | /Unreg | /New

/? Displays help RegPath The registry key or value to open in
Regedit /Unreg Removes RegShortcut's registry entries /New Runs Creates
New Registry Shortcut Wizard Notes
a.. RegShortcut works by pretending to press keys. This means that if a
user is working on the computer and clicks away from Microsoft's Regedit
as it starts then the current application will recieve the key strokes.
RegShortcut takes some precautions to guard against this but is not
bullet proof. b.. This is a Visual Basic 6 application. The run time
library is not included. Download from
ftp://ftp.microsoft.com/Softlib/MSLFILES/vbrun60.exe. To tell if you need
to download this file check to see if Msvbvm60.dll is in your
Windows\System folder. If it is then the run time libraries are already
installed. c.. RegShortcut registers itself in the registry each time
it's run. Therefore to install the file just copy it to any folder and
double click the file. Thereafter it will run just by typing it's name.
It can be renamed or moved, just start the program and it will register
the new name or location. d.. The Registry key must exist. Keys end with
a trailing backslash. Values do not end with a trailing backslash. e.. If
Regedit is already opened, the selection must be in the left hand pane
(the tree pane) for the correct key to open. Download RegShortcut.zip
(15K) includes source files Anyway, to improve Ramesh's script (and to
make it work with the next tip) (note the second last line is still very
long and unchanged). This means it works with arguments

RameshScript.vbs "HKCU\Somewhere"

Set WshShell = CreateObject("WScript.Shell")
Set Ag = WScript.Arguments
MyKey = "My Computer\" & Ag(0)
WshShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Lastkey",MyKey,"REG_SZ"
WshShell.Run "regedit", 1,True

We can now generate a protocol handler
Windows Registry Editor Version 5.00

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\reg]
@="URL:Registry"
"EditFlags"=dword:00000002
"URL Protocol"=""

[HKEY_CLASSES_ROOT\reg\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\

00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,75,00,72,00,\
6c,00,2e,00,64,00,6c,00,6c,00,2c,00,30,00,00,00


[HKEY_CLASSES_ROOT\reg\shell\open\command]
@="wscript \"c:\\OpenRegKey.vbs\" %1"

So typing in Start Run

Reg://HKEY_CLASSES_ROOT\reg\shell\open\command

will open the registry key. You need to fix the reg file (eg it's using
the ftp icon) and as the reg:// gets passed as well one needs to strip
reg:// of the beginning of the string.

So Ramesh's script becomes

Set WshShell = CreateObject("WScript.Shell")
Set Ag = WScript.Arguments
MyKey = Mid(Ag(0),7)
MyKey = "My Computer\" & MyKey
WshShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Lastkey",MyKey,"REG_SZ"
WshShell.Run "regedit", 1,True

I've attached a copy of final script and reg file.
 
D

David Candy

When I wrote that there was no last value stored. Regedit in 98 always opened at the top of the tree.

I suspect Regmon et al are sending messages to the treeview. Which is what the keystrokes get converted into anyway.

I also tried to make it add Reg:\\ if it started with HKEY or in full but it seems to only recognise dots (eg typing www.something adds http://). Putting every registry key seemed silly and time consuming.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top