Managing Registry From Command Line

Registry Editor is a powerful tool to editing or display Windows Registry system. But Windows XP had given us another great tool to edit it; the tool is reg command line. Yup, you have to type it and sure in command line environment. This time, I want write about how to use the reg command.

As you know Registry is windows configuration collections and Windows can’t run without it.
The Registry is composed of mainly two sub trees: HKEY_LOCAL_MACHINE and
HKEY_USERS. But in order to make it easy to find a particular sub tree, they are displayed
as five subtrees in the Registry Editor, three of which are actually aliases of the other sub trees.
Here are the contents of the main subtree of the Registry, as displayed in the Registry
Editor:

  • HKEY_LOCAL_MACHINE Stores information about the hardware, operating system, and other information such as the device drivers and startup configuration of the local computer.
  • HKEY_CLASSES_ROOT Contains information used by various object linking and embedding (OLE) technologies and file class associations.
  • HKEY_CURRENT_USER Contains the profile of the currently logged-on user.
  • HKEY_USERS Contains information about all user profiles and the default profile on the computer. Profiles of users connected remotely are not included in this subtree.
  • HKEY_CURRENT_CONFIG Contains information about the hardware profile that the local computer loaded at startup.

As its default Windows has give us two tools to edit or display the registry, Two tools are Registry Editor you can open it with click StartRun and type regedit in textbox and second tool is Reg command line, you can open it in command prompt/line environment.

This time I just write down about the second tool, Reg command line. To open it just click Start – Run and type cmd in textbox then press Enter key. After your command prompt has opened you’re ready to work.
Reg command has several sub commands and they are :

  1. Reg Add, Used to add a new subkey or an entry to the Registry.
  2. Reg Compare, Used to compare subkeys or entries in the Registry.
  3. Reg Copy, Used to copy a Registry entry to a specified location on a local or remote computer.
  4. Reg Delete, Used to delete a subkey or an entry from the Registry.
  5. Reg Export, Used to copy a subkey, a Registry entry, or a value on the local computer into a file so that it can be transferred to other computers.
  6. Reg Import, Used to copy the contents of a file containing an exported subkey, a Registry entry, or a value from another computer to the Registry of the local computer.
  7. Reg Load, Used to write saved subkeys of the Registry into a different subkey in the Registry. This command is intended for use in troubleshooting Registry problems.
  8. Reg Query, Used to display a list of the next tier of subkeys located directly under the specified subkey in the Registry.
  9. Reg Restore Used to restore saved copies of Registry subkeys.
  10. Reg Save, Used to save a copy of the specified subkeys, entries, and values of the Registry to a specified file.
  11. Reg Unload, Used to delete a part of the Registry that was previously loaded with the Reg Load command.

When you’re work with Reg command the handle key must write with its notations and these are the notations :

  1. HKEY_LOCAL_MACHINE -> HKLM
  2. HKEY_CLASSES_ROOT -> HKCR
  3. HKEY_CURRENT USER -> HKCU
  4. HKEY_USERS -> HKU
  5. HKEY_CURRENT_CONFIG -> HKCC

Registry has several data type and you can look the data type lists here.
For each sub command has its own parameters to combine with them. And to know about their parameters you can tyoe Reg /?. For example Reg query /?
Now, after we are know about the handle key, sub commands, and parameters then you can try it now.
I will write some examples so you can understand how to using it.

  • To display all sub key under Windows key in HKEY_LOCAL_MACHINE : Reg query HKLM\Software\Microsoft\Windows /s
  • To compare two keys : Reg Compare HLKM\Software\Microsoft\DeviceManager HLKM\Software\Microsoft\DeviceManager1 /os
  • To save a key and its subkey : Reg Save HKLM\Software\Microsoft\Windows my_backup.reg
  • To restore from backup key : Reg restore HKLM\Software\Microsoft\Windows my_backup.reg

You can also remote your client computer, for example if you want backup registry from you client you can type : Reg Save \\client_1\HKLM\Software\Microsoft\Windows my_backup.reg or you can restore it : Reg restore \\client_1\HKLM\Software\Microsoft\Windows my_backup.reg.
Hopefully, this article may help you…

(article no:0089)

One Comment

Unlock Hidden Folder Options | Otak Atik [dot] Com  on March 2nd, 2009

[...] you can try this way. The way is using reg command. Just type this command in your Run menu box or DOS console: REG DELETE [...]

Leave a Comment