As of the time of writing this, the accepted answer to this by David Marshall answers the question, but doesn't provide any detail beyond the link itself. In the interest of writing an answer that is both easily readable and invulnerable to potential link rot, I decided to write my own answer to the question.
How do I update the Windows Registry using the command line?
The reg
command, made available from as far back as Windows Server 2000, is used for this exact purpose, and the syntax is fairly simple to use.
To add a key
Run the following in a command line window:
reg add HKLM\Software\Classes\MyKey
...where HKLM\Software\Classes\MyKey is the registry key that you want to create.
To add registry values and data along with keys, parameters are required. The /v
parameter specifies the name of the value to be added, the /t
parameter specifies the value type, and the /d
parameter specifies the data to be contained within the value.
To add the key HKLM\Software\Classes\MyKey
with a DWORD
value named
LegacyDisable
that contains data of 000
:
reg add HKLM\Software\Classes\MyKey /v LegacyDisable /t reg_dword /d 000
To delete a key
reg delete HKLM\Software\Classes\MyKey
Parameters include /v
, for deleting a particular value within a key instead of the key itself; /ve
, to delete a key only if it contains no values; and /f
, which overrides the command's default behaviour of waiting for user confirmation and forces the deletion.
To delete a value within a key:
reg delete HKLM\Software\Classes\MyKey /v LegacyDisable
To compare two keys
The reg
command's compare
also allows you to compare two registry keys, listing the differences between the two by default:
reg compare HKCR\.doc HKCR\.docx
To change the default behaviour of listing differences, and instead list both the differences and similarities between two different keys, use the /oa
parameter.
When adding or modifying a registry key that contains spaces, make sure to wrap the key in quotes to avoid a bad syntax error.
When referring to any of the registry hives in a key path - HKEY_LOCAL_MACHINE
, HKEY_CLASSES_ROOT
, HKEY_CURRENT_USER
,
HKEY_USERS
and HKEY_CURRENT_CONFIG
- the reg
command allows referencing them using their abbreviated versions - HKLM
, HKCR
,
HKCU
, HKU
, and HKCC
respectively - as demonstrated in the examples above.
When a command is about to overwrite a currently-existing value, CMD defaults to prompting for confirmation. To bypass this confirmation, use the /f
parameter to force the overwrite.
The linked Microsoft documentation for the reg
command doesn't list any supported operating systems after Windows 7, so it's currently unclear as to whether this command runs successfuly on either Windows 8 or 10. Input from anyone with these operating systems would be appreciated here.
I found it,
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching]
"SearchOrderConfig"=dword:00000002
and here's a reference for SearchOrderConfig
SearchOrderConfig 0 = Yes, do this automatically
SearchOrderConfig 1 = No, let me choose what to do, Always install the best...
SearchOrderConfig 2 = No, let me choose what to do, Install driver software from windows update ...
SearchOrderConfig 3 = No, let me choose what to do, Never install driver software from Windows update
Best Answer
Take a look:
This is done by creating a user-based GPO that sets the following registry key: