You could simply search for one or the other value with either FIND
or FINDSTR
and invoke commands depending on the result of the search. The pattern would basically be like this:
REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v EnableLUA | (
FIND "0x1" >NUL
) && (
command(s)_to_run_when_UAC_is_enabled
) || (
command(s)_to_run_when_UAC_is_disabled
)
I.e. the REG
produces an output which is passed, using the "pipe" (|
) to the input of FIND
. FIND
looks for 0x1
in its input, and, depending on the result of the search, one of the following bracketed blocks of commands is executed.
The command && command || command
is a standard mechanism that allows you to selectively run commands, a kind of replacement for IF
. The first command produces a result. The command just after &&
runs if the result is "success", and the command just after ||
runs in case of a fail.
If you need to perform actions in both cases, use both &&
and ||
after the command generating the result, but if only one kind of result should be reacted to, you can leave out either &&
or ||
.