Check for multiple registry keys in batch file -


i need check registry multiple keys before start program (they shouldn't exist). spread solution checking registry keys works 1 check since sets global errorlevel 1. example below won't work correctly.

@echo off  reg query hkey_local_machine\software\mykey >nul if %errorlevel% equ 0 (     echo "mykey exists - nothing" ) else (     reg query hkey_local_machine\software\mykey2 >nul      if %errorlevel% equ 0 (          echo "mykey2 exists - nothing"     ) else (          run program     ) ) 

using errorlevel require delayed expansion.you can try if errorlevel

@echo off  reg query hkey_local_machine\software\mykey >nul if %errorlevel% equ 0 (     echo "mykey exists - nothing" ) else (     reg query hkey_local_machine\software\mykey2 >nul      if errorlevel 1 (          run program     ) else (          echo "mykey2 exists - nothing"     ) ) 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -