You probably use Control Panel or other tools for most server-tuning tasks, but some recommended fixes require you to edit the registry by hand. Manually editing the registry can easily mess up your OS to the point of no return, so if a registry modification is important enough to make by hand, it's important enough to make consistently on all applicable computers. You probably also want to document the registry edit and its purpose, as well as confirm the changes.
If you've ever manually edited the registry on more than a few computers, you probably know one way to make changes without navigating through the HKEY maze more than once. You can save the edited key as a .reg file, then import that file to all the computers that need the same fix. However, that approach doesn't log the change and supports only a limited amount of granularity (you can import a key, but you can't import one edited value). A better approach is to use VBScript to write your change to the registry and record changes in the computer's Application log so that youand otherscan tell what edits you've made and why. You can modify the same script to read the registry and thus confirm your changes.
A Good Example
You can edit any part of the registry through VBScript, but for an example, let's suppose that you're editing the registry on your application servers so that a particular application will refer to usernames instead of computer names. The edit is application-specific, so you must be sure to edit the correct application's subkey. The subkey's final edited value is the sum of two hexadecimal numbers (rather than something easy, such as 0 or 1), so you must be sure to enter the right number on all application servers. The edit's purpose isn't obvious, so you'll want a record explaining the edit.
To accomplish these goals, you need a script that performs several tasks. The script must create a WshShell object (which represents the Windows Shell and thus gives you programmatic access to the registry-editing tools and Event Viewer), write the change to the registry, and record the change in the Application log.
Writing the Change
I discuss WshNetwork, a Windows Script Host (WSH) 2.0 object representing network-accessible printers and drives, in "Connecting to Printers," August 2002, http://www.winnetmag.com, InstantDoc ID 25652, and "Connecting Users to Network Resources," June 2002, http://www.winnetmag.com, InstantDoc ID 24893. WshShell, another WSH object, deals with certain Windows Shellrelated objects, including the registry editor and Event Viewer.
WshShell supports several methods for reading or editing the registry. Generally, using the registry-editing methods is simple as long as you're exact; putting even an extra space in the string will return an error. For this example, you're going to work with the RegRead method, which reads a subkey or value, and the RegWrite method, which writes a subkey or value. These methods use a simple syntax:
WshShell.RegRead strName
and
WshShell.RegWrite strName, varValue, [strtype]
Prev. page  
[1]
2
next page