I am trying to check and update the network zone mapping in the registry from the Command Prompt. I need to check for the value named *
. For example, under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\cmich.local, Registry Editor shows the following:
* REG_DWORD 0x00000001 (1)
To check this value in a command script (*.cmd), I have been attempting to use the REG QUERY command. When I attempt to do so by passing *
as the value to match, the REG QUERY command treats the asterisk as a wildcard and returns a match as long as the key exists.
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\example.com" /v "*" /reg:64
I've tried numerous combinations of escape characters (even those that I was pretty sure wouldn't work), including all of the following with and without quotation marks: *
, \*
, ^*
, `*
, `*`
, !*
. None of these worked.
I also need to add and remove values with the name *
, presumably with REG ADD and REG DELETE.
How do I add, remove, and test for the existence of a registry value with the name *
at the Command Prompt?
The tricky part of checking a registry value named
*
(actually a wildcard of meaning all):?
wildcard i.e. at most one character, and*
usingfindstr
utility;reg query "%_TestKey%" /v ? | findstr /I /C:" * REG_"
could suffice.The following batch-file code snippet shows that there is no issue with adding, removing or changing a value named
*
.The code is commented using
<NUL set /P =::: …
trick i.e.echo ::: …
with no ending CRLF to show comments in output with minimum of empty lines.Output: