Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


April 2001

Distributing Registry Changes


RSS
Subscribe to Windows IT Pro | See More Registry Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!
SideBar    A Registration File Drawback, Registry Data Types, Make the Connection

Script File Guidelines
The script file you use with Regini can have any name and extension you want. The file must be in ANSI format; regini.exe converts the file to Unicode when it reads the file, but you can't use a Unicode text file as the script file. (Microsoft should fix this limitation.) Registry commands in this script file must use the following syntax:

\Registry\<KeyPath> [<ACL>]
<DataItemName> = <DataType> <DataValue>

The presence of an equal sign in a line indicates that the line contains a registry data item and a value that you're adding, deleting, or modifying.

Lines in the script must have a carriage return at the end. If a line wraps, which usually happens when the registry key is deeply nested and therefore very long, the continuation symbol is a backslash. So, if you enter

SomethingMorestuff Evenmore

regini.exe reads the line as SomethingMorestuff Evenmore. Note that the space before the backslash on the second line inserts a space between Morestuff and Evenmore. If no space is required (i.e., if the point at which the wrapping occurs isn't a natural space such as the space within the name of a subkey), omit the space before the backslash.

The first line of each registry command contains the KeyPath variable, which is the full path to the key you're manipulating. If the key doesn't exist in the registry when you run the script, the command will add it. Regini.exe uses the kernel naming conventions for registry subtrees, and you can either enter kernel names in your script or use standard subtree names and let regini.exe translate them. (The kernel conventions are easier to type.) The kernel naming conventions for subtrees are as follows:

  • HKEY_LOCAL_MACHINE is \Registry\Machine
  • HKEY_USERS is \Registry\User
  • HKEY_CURRENT_USER is \Registry\User\User_SID

The first line can also contain an optional ACL variable. You can include this variable to manipulate ACL permissions instead of, or in addition to, keys and data items. The ACL data comes after the KeyPath variable and consists of a series of numbers separated by spaces and enclosed within square brackets. (Table 2 lists these numbers and their meanings.) For example, the following command:

\Registry\machine\system\currentcontrolset [1 11 17]

assigns Administrators Full Access, Power Users Full Access, and System Full Access permissions to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet registry subkey.

Watch out: This feature is dangerous if you don't understand the way it works. When you use this feature, you aren't adding the ACL permissions that you enclose within the brackets—you're resetting the ACLs. The data within the brackets replaces any existing data. Don't use this feature unless you first check the existing ACL for the key you're manipulating. (You can use regedt32 to view the ACL.) Otherwise, you might accidentally eliminate or modify permissions for a group.

The second line contains the information for the data item you're manipulating: DataItemName is the name of the data item and consists of every character from the first nonblank character on the line to the last nonblank character before the equal sign. You don't need to use a special format (e.g., enclosing the name in quotation marks) to handle data items with spaces. If the data item doesn't exist in the registry when you run the script, the command will add it.

DataType is the data type for the data item. Regini recognizes the text to the right of the equal sign, up to the first space, as the data type.

DataValue represents the value you're applying to the data item. This value begins with the first nonblank character following the space after the data type and continues to the end of the line. You don't need to use any special handling to specify spaces within a value.

Regini.exe expects the data type and its accompanying value in your script to match certain standards. These standards are as follows:

  • REG_SZ or REG_EXPAND_SZ for string values.
  • REG_MULTI_SZ for multiple strings. You must surround each string with quotation marks.
  • REG_DWORD for decimal or hex values. For REG_DWORD data items, the default value is decimal. Use 0x to specify a hex value. If you enter the value On, True, or Yes, the value is converted to 0x00000001; if you enter the value No, False, or Off, the value is converted to 0x00000000.
  • REG_BINARY for binary values formatted as two or more decimal numbers. The first decimal number specifies the number of bytes of data that follow. The remaining numbers are converted into 32-bit numbers. (The value length must always be a multiple of 4 bytes.)
   Previous  1  2  [3]  4  5  6  Next 


Reader Comments
<br>In "Distributing Registry Changes" (April 2001), Kathy Ivens states, "Registration (.reg) files can't delete anything in the registry." They can! I use .reg files to customize my desktop at startup, and one of the registry subkeys I delete is HKEY_CURRENT_
USER\Software\Microsoft\WindowsCurrentVersion\Explorer\MenuOrder. Deleting this key makes the contents of my Favorites and Start Menu folders appear in alphabetical order. In the .reg file, I simply insert a hyphen (-) inside the brackets that enclose the registry path to the subkey that I want to delete. However, I'm not sure how to use .reg files to delete individual registry values. I usually just delete the entire key and reimport the values I want.<br>

Patrick S. Seymour June 19, 2001


<br><i>You're correct, and several readers pointed out the error. In fact, deleting keys and items with a .reg file is dangerously easy. Putting a hyphen at the beginning of the registry path deletes the key. To delete an individual data item in a registry key, use this format in the .reg file.<br><br>
&lt;RegistryEditorVersion&gt;<br><br>

[&lt;RegistryPath&gt;] <br>
"&lt;DataItemName&gt;"=- <br><br>

The best way to proceed is to use regedit to export the key, then edit the .reg file and insert the appropriate hyphens. Use Save As, and apply a new filename to this revised .reg file. That way, you can make sure the original values are still available in case you do something wrong or change your mind. Just double-click your new .reg file to merge its contents into the registry.</i><br>
<i>--Kathy Ivens</i>

Kathy Ivens June 19, 2001


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

New Microsoft/Yahoo! Deal? No

On Sunday, the Times of London reported that Microsoft had renewed talks with failing Internet giant Yahoo! and would manage its search engine for 10 years, while Yahoo! would retain control of its email, messaging, and content services. This report ...

How can I stop and start services from the command line?

...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing