Registry data refreshed from vendors: Last vendor change detected: 5 Dec 2026Next refresh: 1st of the monthApp v1.4.0 (5 Dec 2026): Cleanup or tattoo: see what stays behind after a GPO is removed. Release notes
REGISTRY ACADEMY · LESSON 2 OF 10

reg.exe from the command line

Query, add, delete, export, save, restore, load and compare registry data with the built-in reg command.

reg.exe ships with every Windows release, works in Server Core, in WinPE and from any script, and can target remote computers. Run it elevated for HKLM writes.

The subcommands

CommandDoes
reg queryRead keys and values; /s recurses, /f searches, /v picks a value
reg addCreate a key or set a value (/t type, /d data, /f no prompt)
reg deleteRemove a value (/v), all values (/va) or the key
reg copyCopy a key to another path, optionally on another computer
reg export / reg importWrite or read a .reg text file
reg save / reg restoreWrite a branch to a binary hive file / overwrite a branch from one
reg load / reg unloadMount an offline hive file under HKLM or HKU and detach it
reg compareDiff two keys, locally or across computers
reg flagsView or set virtualization flags on HKLM\SOFTWARE subkeys

Everyday examples

:: read one value
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections

:: find every value or key containing "Citrix" under SOFTWARE (keys, values and data)
reg query HKLM\SOFTWARE /f Citrix /s

:: set a DWORD (decimal) without a prompt
reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f

:: set a multi-string (\0 separates entries)
reg add "HKLM\SOFTWARE\FSLogix\Profiles" /v VHDLocations /t REG_MULTI_SZ /d "\\fs01\profiles\0\\fs02\profiles" /f

:: delete a value
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoUpdate /f

:: 32-bit view on 64-bit Windows
reg query HKLM\SOFTWARE\Contoso /reg:32

Backup before a change

reg export "HKLM\SOFTWARE\Citrix\VirtualDesktopAgent" C:\Backup\vda-before.reg /y
reg save   "HKLM\SOFTWARE\Citrix\VirtualDesktopAgent" C:\Backup\vda-before.hiv /y

Use export for human-readable files you can diff and partially re-import. Use save/restore for an exact binary copy that includes security descriptors; reg restore replaces the whole branch.

Remote computers

Prefix the key with \\computer\. Remote access only reaches HKLM and HKU and needs the Remote Registry service on the target (see Remote registry).

reg query \\srv01\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp /v PortNumber
reg compare \\srv01\HKLM\SOFTWARE\Contoso \\srv02\HKLM\SOFTWARE\Contoso /s

Exit codes in scripts

reg returns 0 on success and 1 on failure; reg compare returns 0 when identical and 2 when different. Check %ERRORLEVEL% (cmd) or $LASTEXITCODE (PowerShell).

Reference: reg command reference (Microsoft Learn).