Re: Navigating The Registry
From: David Candy (.)
Date: 02/02/05
- Next message: Soylent Green: "Re: Drive letter assignment"
- Previous message: parkman1947: "RE: InstallShield"
- In reply to: Terry: "Re: Navigating The Registry"
- Next in thread: Terry: "Re: Navigating The Registry"
- Reply: Terry: "Re: Navigating The Registry"
- Reply: Ramesh, MS-MVP: "Re: Navigating The Registry"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 2 Feb 2005 13:42:52 +1100
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.
-- ---------------------------------------------------------- http://www.uscricket.com "Terry" <F1ComNOSPAM@pobox.com> wrote in message news:uyA2xnLCFHA.3696@TK2MSFTNGP14.phx.gbl... > 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.
- application/octet-stream attachment: OpenRegKey.vbs
- application/octet-stream attachment: 1.reg
- Next message: Soylent Green: "Re: Drive letter assignment"
- Previous message: parkman1947: "RE: InstallShield"
- In reply to: Terry: "Re: Navigating The Registry"
- Next in thread: Terry: "Re: Navigating The Registry"
- Reply: Terry: "Re: Navigating The Registry"
- Reply: Ramesh, MS-MVP: "Re: Navigating The Registry"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|