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
Post a Comment