Manipulate Windows Registry from the Command Line

The Registry Editor, or regedit.exe, allows the import and export of Windows registry entry files from the command line. It’s usage though, could prove to be a bit restrictive from the command line. From Windows XP edition onwards, Microsoft has included another command line tool called REG, or reg.exe. This tool is able perform almost all the tasks as it’s GUI counterpart – regedit.exe.

Query the Registry

REG allows you to query specific keys and values. It also allows recursive and case sensitive searches.

To get a list of programs that are run when your computer starts, run REG as:

To query a specific value, run REG as:

Add to Registry

To add a new software to the startup list, run REG as:

Note that you will need an Administrator Command Prompt to add entries to the registry.

Delete from Registry

To delete the entry we have created in the example above, run REG as:

Note the presence of the command ‘echo Y|’ piped to reg. This sends the ‘Y’ character to the delete confirmation prompt. To delete without the prompt, run REG as:

Alternative Ways to Access the Registry from the Command Line

If you have Cygwin installed, you can access the registry from the directory /proc/registry/, which is part of the /proc virtual filesystem. Another tool under Cygwin is regtool. To find out more about regtool, refer to the man pages.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }