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
in progress 0
Configuration Manager 2 years 2020-10-23T15:09:23+05:30 2020-10-23T15:09:23+05:30 3 Answers 660 views Beginner 0
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