Need a script to check registry key value existing or not
Question
I need to create a batch file to check a particular registry value is existing or not
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
I need to create a batch file to check a particular registry value is existing or not
Answers ( 3 )
Hello Akash – Any update on this! Did you able to achieve your requirements
Hi one suggestion use configuration baseline if you only want to check registry key value exist or not.
Hello, You can try something like this –
For Example :-
@echo off
reg query mykey >nul
if %errorlevel% equ 0 (
echo “mykey exists- do nothing”
) else (
echo “mykey does not exist – add the key and give it a value”
reg add mykey
reg add mykey /v value …
)
This command will set %errorlevel%.
errorlevel=0 key exists.
errorlevel=1 key doesn’t exist.
reg add key To add a key if it is not present
Reference link – https://docs.microsoft.com/en-us/powershell/scripting/samples/working-with-registry-entries?view=powershell-6