CMD Simulator
Advanced System Toolsreg

REG Command – Registry Console Tool in Windows CMD

Learn how to use the REG command to query, add, delete, and manage Windows Registry from the command line. Guide covers REG QUERY, REG ADD, REG DELETE, syntax, and examples.

Rojan Acharya·
Share

The REG command is a Windows Command Prompt utility that adds, changes, and displays registry subkeys and values from the command line. Use REG QUERY to read registry data, REG ADD to create or modify values, or REG DELETE to remove keys and values—essential for scripting, deployment, and configuration management without using the Registry Editor GUI.

Whether you're a system administrator deploying registry changes across multiple computers, a developer automating registry configuration for software installation, or an IT professional troubleshooting registry-related issues, REG provides full command-line access to the Windows Registry. Automation engineers rely on REG for batch configuration, deployment scripts, and consistent registry management across enterprise environments.

This comprehensive guide covers REG syntax, QUERY/ADD/DELETE/EXPORT operations, practical examples for common scenarios, troubleshooting tips, related commands, and frequently asked questions. By the end, you'll confidently use REG for registry management and scripting in Windows environments.

What Is the REG Command?

The REG command is the command-line interface to the Windows Registry. It supports querying keys and values, adding and modifying registry data, deleting keys and values, exporting and importing registry files, and comparing registry content. REG is available in Windows 2000 and later, including all Windows 10, Windows 11, and Windows Server editions.

The Windows Registry stores configuration data for the operating system and applications. REG allows you to read and modify this data from scripts and command line without opening Regedit.exe. Use REG for deployment automation, configuration management, and troubleshooting.

REG vs Registry Editor (regedit)

  • REG: Command-line; scriptable; automation; batch operations
  • Regedit: GUI; interactive; registry file import/export; visual browsing
  • Use REG for scripts and automation; use Regedit for interactive editing.

Syntax

REG QUERY | ADD | DELETE | COPY | SAVE | LOAD | UNLOAD | RESTORE | COMPARE | EXPORT | IMPORT

Common Operations

OperationDescription
REG QUERYDisplays registry keys and values
REG ADDAdds or modifies registry keys and values
REG DELETERemoves registry keys or values
REG EXPORTExports registry to a file
REG IMPORTImports registry from a file

Registry Hives (Abbreviations)

AbbreviationFull Path
HKLMHKEY_LOCAL_MACHINE
HKCUHKEY_CURRENT_USER
HKCRHKEY_CLASSES_ROOT
HKUHKEY_USERS
HKCCHKEY_CURRENT_CONFIG

Value Types

TypeDescription
REG_SZString
REG_DWORD32-bit number
REG_QWORD64-bit number
REG_MULTI_SZMultiple strings
REG_EXPAND_SZExpandable string (environment variables)

How to Use REG Command

Query a Registry Key

Display registry key contents:

REG QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion

Query specific registry path:

REG QUERY HKLM\SOFTWARE\MyApp /v Version

Add a Registry Value

Create or modify a registry value:

REG ADD HKLM\SOFTWARE\MyApp /v Version /t REG_SZ /d "1.0" /f
  • /v = value name
  • /t = type (REG_SZ, REG_DWORD, etc.)
  • /d = data
  • /f = overwrite without prompt

Add a Registry Key

Create a key (no value):

REG ADD HKLM\SOFTWARE\MyApp

Delete a Registry Value

Remove a value:

REG DELETE HKLM\SOFTWARE\MyApp /v Version /f

Delete a Registry Key

Remove a key and all subkeys:

REG DELETE HKLM\SOFTWARE\MyApp /f

Export Registry

Export registry to file:

REG EXPORT HKLM\SOFTWARE\MyApp backup.reg

Import Registry

Import registry from file:

REG IMPORT backup.reg

Common Use Cases

  1. Software deployment – Add registry keys during installation for application configuration.

  2. Configuration management – Apply registry changes across multiple computers via scripts.

  3. Backup before changes – Export registry before modifying: REG EXPORT before REG ADD/DELETE.

  4. Troubleshooting – Query registry to verify configuration values and paths.

  5. Policy enforcement – Set registry values to enforce security or application settings.

  6. Uninstall cleanup – Remove application registry keys during uninstall scripts.

  7. Environment migration – Export registry from one system and import to another for configuration transfer.

  8. Audit and compliance – Query registry to verify configuration compliance.

  9. Development and testing – Automate registry setup for test environments.

  10. Remote management – Use REG with /S for remote computer registry operations.

Tips and Best Practices

  1. Always backup before editing – Use REG EXPORT before REG ADD or REG DELETE. Restore point is recommended for system keys.

  2. Use /f for scripted operations – /f suppresses prompts; necessary for unattended scripts.

  3. Specify value type explicitly – Use /t REG_SZ, REG_DWORD, etc. to avoid type errors.

  4. Test on non-production first – Verify REG commands work correctly before applying to production.

  5. Use full paths – Specify complete registry path: HKLM\SOFTWARE\Vendor\App\Key.

  6. Document registry changes – Maintain runbook of registry modifications for rollback.

  7. Run as Administrator when needed – Some keys (HKLM\SYSTEM, HKLM\SAM) require elevation.

  8. Quote paths with spaces – Use quotes for paths containing spaces: REG ADD "HKLM\...\Path With Spaces".

Troubleshooting Common Issues

"Access is Denied" When Modifying Registry

Problem: REG ADD or REG DELETE fails with access denied.

Cause: Insufficient permissions. Some keys (HKLM\SYSTEM, HKLM\SAM, HKLM\SECURITY) require SYSTEM or Administrator. Some keys are protected.

Solution: Run Command Prompt as Administrator. For protected keys, use SYSTEM or appropriate service account. Check key permissions with Regedit (right-click key > Permissions).

Prevention: Document required permissions. Use RUNAS or elevated prompt for protected keys.

"The system was unable to find the specified registry key"

Problem: REG QUERY or REG DELETE fails with key not found.

Cause: Key path is incorrect; key doesn't exist; typo in path.

Solution: Verify path with REG QUERY on parent key. Use Regedit to browse and confirm path. Check for extra spaces or wrong hive abbreviation.

Prevention: Test REG QUERY before REG ADD/DELETE. Use REG EXPORT to backup and verify path.

"Invalid key name" or "Invalid value name"

Problem: REG command fails with invalid key or value name.

Cause: Key or value name contains invalid characters; path format is wrong.

Solution: Ensure path uses backslashes. Use correct hive abbreviations (HKLM, HKCU, etc.). Avoid special characters in value names. Quote paths with spaces.

Prevention: Follow registry path format: HIVE\Key\Subkey. Use /v for value name.

REG IMPORT Fails or Has Unexpected Results

Problem: REG IMPORT doesn't work or produces wrong results.

Cause: .reg file format may be incorrect; file may be corrupted; encoding issues.

Solution: Verify .reg file format (Windows Registry Editor Version 5.00 header, correct paths). Ensure file is UTF-16 or ANSI. Test import on non-critical system first.

Prevention: Generate .reg files with REG EXPORT when possible. Validate file format before import.

Related Commands

REGEDIT – Registry Editor

Regedit is the GUI for registry editing. REG is command-line; Regedit is interactive.

When to use: Interactive browsing and editing vs. scripted operations.

REG ADD – Create/Modify

REG ADD creates keys and values. Use for deployment and configuration scripts.

When to use: Adding or updating registry data.

REG QUERY – Read

REG QUERY reads registry. Use for verification and troubleshooting.

When to use: Checking registry values before or after changes.

WMIC – WMI Registry

WMIC can query registry via WMI. REG is simpler for direct registry operations.

When to use: REG for direct registry; WMIC for WMI-based queries.

PowerShell – Registry Provider

PowerShell has Registry provider (HKLM:, HKCU:). Use for complex PowerShell scripts.

When to use: REG in CMD/batch; PowerShell provider in PowerShell scripts.

Frequently Asked Questions

What does the REG command do?

REG is the Windows Registry console tool. It adds, changes, and displays registry subkeys and values from the command line. Use REG QUERY to read, REG ADD to create/modify, REG DELETE to remove.

How do I query the registry with REG?

Use REG QUERY keypath to display a key's contents. Example: REG QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion. Add /v ValueName to query a specific value.

How do I add a registry value with REG?

Use REG ADD keypath /v ValueName /t Type /d Data /f. Example: REG ADD HKLM\SOFTWARE\MyApp /v Version /t REG_SZ /d "1.0" /f. The /f flag overwrites existing value without prompt.

How do I delete a registry key?

Use REG DELETE keypath /f. Example: REG DELETE HKLM\SOFTWARE\MyApp /f. The /f flag suppresses confirmation. To delete only a value: REG DELETE keypath /v ValueName /f.

What registry hives can I use?

Use HKLM (HKEY_LOCAL_MACHINE), HKCU (HKEY_CURRENT_USER), HKCR (HKEY_CLASSES_ROOT), HKU (HKEY_USERS), HKCC (HKEY_CURRENT_CONFIG). Abbreviations are required in REG commands.

Can REG work on remote computers?

Yes. Use /S \\computername for remote operations. Example: REG QUERY \\SERVER01\HKLM\SOFTWARE\MyApp. Requires admin rights on remote computer.

How do I backup registry before making changes?

Use REG EXPORT keypath filename.reg to export a key to a file. Example: REG EXPORT HKLM\SOFTWARE\MyApp backup.reg. Restore with REG IMPORT if needed.

What is the difference between REG_SZ and REG_DWORD?

REG_SZ stores string data. REG_DWORD stores 32-bit integer. Use REG_SZ for text (e.g., "1.0"); use REG_DWORD for numbers (e.g., 1 for enable, 0 for disable).

Can REG delete the default value?

Yes. The default value is "(Default)". Use REG DELETE keypath /ve /f to delete the default value. /ve specifies the default (empty name) value.

How do I add a REG_DWORD value?

Use REG ADD keypath /v ValueName /t REG_DWORD /d value /f. Example: REG ADD HKLM\SOFTWARE\MyApp /v Enabled /t REG_DWORD /d 1 /f. Use 0 or 1 for boolean flags.

Quick Reference Card

CommandPurposeExample Use Case
REG QUERY keypathDisplay key contentsVerify registry values
REG ADD keypath /v name /t REG_SZ /d "data" /fAdd string valueConfiguration
REG ADD keypath /v name /t REG_DWORD /d 1 /fAdd DWORD valueEnable/disable flags
REG DELETE keypath /fDelete keyUninstall cleanup
REG DELETE keypath /v name /fDelete valueRemove single value
REG EXPORT keypath file.regExport to fileBackup before changes
REG IMPORT file.regImport from fileRestore registry

Try REG Command Now

Practice registry operations in our Windows Command Simulator. Explore WHOAMI for user context, SCHTASKS for task automation, and the full Commands Reference for more Windows CMD utilities.

Summary

The REG command provides command-line access to the Windows Registry for querying, adding, modifying, and deleting keys and values. Use REG QUERY to read registry data, REG ADD to create or update values with /v, /t, and /d parameters, REG DELETE to remove keys or values, and REG EXPORT/IMPORT for backup and restore. REG supports all registry hives (HKLM, HKCU, etc.) and value types (REG_SZ, REG_DWORD, etc.). Always backup with REG EXPORT before making changes. Use /f for scripted operations to suppress prompts. Run as Administrator when modifying protected keys. Master REG for registry management and configuration automation in Windows deployment and scripting.