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 


January 2004

Integral Reg

Command-line registry power at your fingertips
RSS
Subscribe to Windows IT Pro | See More Resource Kit Articles Here | Reprints

The central importance of the registry in the Windows server environment demands some kind of command-line control of registry settings. The Microsoft Windows NT Resource Kit has offered Reginfo as far back as NT 3.5 or NT 3.1, but Windows 2000 and later come with a useful and—at least in my experience—more reliable tool in reg.exe. Unlike Reginfo, the Reg command is built into the OS, so you don't need to install it.

Several Reg options are available. The Query option lets you perform searches, the Add option lets you add or change keys and values, and the Delete option lets you delete values or keys. You can use the Save and Restore options to back up and restore pieces of the registry to hive files. The Copy option lets you copy entire chunks of a remote system's registry to your computer's registry. And, finally, the Export and Import options let you export and import pieces of the registry to or from Unicode text files.

A comprehensive explanation of Reg's syntax would require more space than I have, so instead I offer some sample scenarios that illustrate Reg's usefulness. To use Reg, you must have the correct permissions; typically (but not always), you need to be an administrator. The ACL of the registry component you want to modify decides whether you can run a given Reg command. Also, Reg isn't case sensitive, except when you're feeding the registry data—some registry subkeys are case sensitive, so be sure to type data values as the registry requires.

Most commonly, I use Reg to change an existing registry value or to add a new value. For example, suppose I want to add to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters subkey a value called CrashOnCtrlScroll (of type REG_DWORD) that's set to 1. This value would let me use the Ctrl+Scroll Lock key combination to force a blue screen on my system—a useful capability for determining the causes of lockups. The entry doesn't exist by default on Windows Server 2003, Windows XP, or Win2K systems, so I need to use Reg to create the entry and give it a value of 1:

reg add HKLM\SYSTEMCurrentControlSet\Services\i8042prt
\Parameters /v CrashOnCntrlScroll /t REG_DWORD /d 1 /f

The first part of the command points to the registry key I want to modify. Notice that Reg accepts the shorthand HKLM instead of HKEY_LOCAL_MACHINE. The /v parameter followed by CrashOnCtrlScroll tells Reg to create or modify the value entry by that name. The /t parameter determines the type of value entry, the /d 1 parameter tells Reg to fill the subkey with a value of 1, and the /f parameter tells Reg to overwrite the value if necessary. (Without this final parameter, if a CrashOnCtrlScroll entry exists, Reg will stop and ask "Are you sure?") Now, I can place this command line inside a batch file, then run that batch file on any system to enable the forced­blue screen key sequence.

Here's another scenario in which Reg proves useful. When you open a shared folder in Windows 2003, XP, or Win2K, you might notice that Windows Explorer displays its flashlight icon while it seems to search for something. Even if the share contains only a few files, Windows Explorer searches the folder for Scheduled Tasks. To instruct Windows Explorer not to perform this search, you can use Reg to delete the entire HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\Namespace\{D6277990-4C6A-11CF-8D87-00AA0060F5BF} registry subkey:

reg delete HKLM\SOFTWARE\Microsoft\Windows
\CurrentVersion\Explorer\RemoteComputer\Namespace
\{D6277990-4C6A-11CF-8D87-00AA0060F5BF} /f

The syntax for this command is simple to follow. Only two parameters follow Reg Delete: the name of the key you want to delete and the /f option. You don't need to reboot to effect this deletion.

The prospect of deleting a registry subkey might concern you. You might wonder how you would restore the key, should you decide you need it. To avoid this dilemma, you can use Reg's Export option to export the subkey before you delete it:

reg export HKLM\SOFTWARE\Microsoft\Windows
\CurrentVersion\Explorer\RemoteComputer\Namespace
\{D6277990-4C6A-11CF-8D87-00AA0060F5BF} backup.reg

This command exports the key in Unicode format and creates a familiar .reg file, which you've probably seen Regedit create. To import the file later, you simply use the Reg Import command, followed by the same information—remember to add the /f parameter to prevent Reg from asking you for confirmation.

These scenarios represent only a sampling of what Reg can do. Take your favorite Reg commands and make batch files of them. Then, when trouble calls, you can have a CD-ROM full of batch files at the ready.

End of Article



Reader Comments
After reading this article I was quite excited to try the reg.exe utility. I tried both on Win2K Advanced Server and Win2K Professional, but neither had this utility. I searched my entire PC for the reg.exe and reg.* and found nothing. On my laptop (Windows XP Pro) I had no problem, but would like to use this on my server. What am I doing wrong...is this a utility that must be installed. In the article it states that it comes built in to the OS, but is it an optional part of the OS?

Wilson Steiger April 26, 2004


For Windows 2000, reg.exe only comes with the Resource Kit, I believe; for Windows XP, it's built in.

Robert Morley June 30, 2004


I've found the REGINI.EXE tool from the Windows 2000 Server resource kit far more powerful. In addition to doing everything that REG.EXE can do, REGINI.exe can also change permissions on registry keys. Useful if, say, you want to allow everyone to update HKLM\CLSID\FormFlow.Form (this, with other registry permissions changed, stops an annoying popup for non-administrators on Windows 2000/XP when they try FormFlow).

Chris Keene July 02, 2004


What are the alternatives on other OS's?

msteudel February 02, 2005 (Article Rating: )


Most other OSes do not have anything like the registry, which is basically an OS internals obfuscation mechanism.

Some folks say the registry obscures the details of OS configuration on purpose, to lock out other vendors; some say that the windows OS is so grossly inefficient it must have a pre-digested binary configuration in order to achieve reasonable interface response.

Other OSes have configuration interfaces that are human-readable, rather than binary blobs... for example, in unix-derived systems there are configuration directories containing configuration files; they correspond to hives and keys but can be manipulated with simple text editor (and more importantly, they can be COMMENTED for human comprehension).

Compaq/DEC VMS and IBM's OS390/MVS and OS/400 systems also use human-readable configuration systems.

Most people outside the windows hothouse consider the registry to be an abomination.

Anonymous User February 25, 2005


reg is known as regedit on win2k

Anonymous User April 18, 2005 (Article Rating: )


Excelent Tutorial, it was pretty useful, thanks a lot



Anonymous User May 05, 2005 (Article Rating: )


You must log on before posting a comment.

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




Top Viewed ArticlesView all articles
Managing Virtual Sprawl

As some wise person once said, nothing is ever truly free. Such is the case with VMs, which can quickly mutate from a cost-reducing Dr. Jekyll into a time-consuming, profligate nightmare that would do Mr. Hyde proud. ...

WinInfo Short Takes: Week of May 19, 2008

An often irreverent look at some of the week's other news, including OLPC and Windows XP, the XP SP3 constant reboot issue, Yahoo! vs. Icahn, 10 million Xbox 360s in North America, April video game stats, Microsoft innovation, CBS and CNET, and much more ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...


Task Automation Whitepapers One Less Fire: Automating System Performance and Reliability

Maximizing Site Visitor Trust Using Extended Validation SSL

St. Bernard Managed Protection Services

Related Events Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Order Windows IT Pro VIP and SAVE!!
Get it all with Windows IT Pro VIP A $500+ value foir only $279!

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

Buy One Get One!
Order Windows IT Pro & Get SQL Server Magazine FREE!

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




ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

EXCHANGE 2007 Mastery Series – May 29, 2008
3 Info-packed eLearning seminars for only $99! Learn the pros and cons of your mailbox high availability options, see real-world examples of Transport Rules, and get started with basic PowerShell commands with Mark Arnold, MCSE+M and Microsoft MVP.

Windows IT Pro Master CD: Take the Experts with You!
Find the solutions you need in thousands of searchable articles, helpful bonus content, and loads of expert advice with the Windows IT Pro Master CD. Order comes with a 1-year subscription to the new, online articles posted every day!

Making the Case for Oracle Database on Windows
One of the best-kept secrets in the IT industry is the depth of support Oracle offers to customers deploying its databases on Microsoft Windows platforms.

SQL Server Magazine Master CD: Take the Experts with You!
Find the solutions you need in thousands of searchable articles, helpful bonus content, and loads of expert advice with the SQL Server Magazine Master CD. Order comes with a 1-year subscription to the new, online articles posted every day!

Attention User Group Leaders...
Announcing the eNews Generator—a FREE HTML e-newsletter builder for user group leaders. Build your HTML and text e-newsletters in minutes. And add Windows IT Pro & SQL Server Mag articles alongside your own message!.

Become a fan of Windows IT Pro on Facebook
Join the Windows IT Pro fan club on Facebook. Chat with other IT Pros, upload your pictures, check out what's up n' coming in the next issue and more!



Solve the 12 Toughest Active Directory Management Tasks Today
No matter which management tasks you’re dealing with, you’ll discover a new set of ideas about how to best manage your Active Directory environment.

Get Started with Oracle on Windows DVD
Learn how Oracle gives you the power to grow by providing a scalable, easy-to-use platform for running your business at a price you can afford.

Exchange and Outlook Update Fundamentals CD
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.

Virtualization Essentials – Free Online Conference :: June 24th
Learn virtualization basics - Discover how to reduce IT costs while increasing the efficiency, utilization, and flexibility of your existing computer hardware. Register Today!

Gain enhanced insight into and control over your IT systems.
View this web seminar to learn about the latest and greatest features and product enhancements in the Systems Center Configuration Manager SP1 and R2.

11 Myths About Microsoft Exchange Backup & Recovery
This white paper will guide you in overcoming Exchange Backup and Recovery myths with careful planning and the right toolset.
Windows IT Pro Home Register About Us Affiliates / Licensing Press Room Media Kit Contact Us/Customer Service  
SQL Connected Home IT Library SuperSite FAQ Wininfo News
Europe Edition Office & SharePoint Pro Windows Dev Pro Windows Excavator 
 
 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