I have this program that claims to determine if DOSBOX is installed on the system regardless of the location of the executable folder
@echo off
setlocal EnableDelayedExpansion
echo Search DOSBox
REM Búsqueda en registro de 32 bits
set "FOUND=0"
for /f "tokens=2 delims==" %%a in ('wmic product where "name like '%%DOSBox%%'" get name /value 2^>nul') do (
echo DOSBox encontrado: %%a
set "FOUND=1"
)
REM Búsqueda en registro de 64 bits
if %FOUND%==0 (
for /f "tokens=2 delims==" %%a in ('wmic product where "name like '%%DOSBox%%'" get name /value 2^>nul') do (
echo DOSBox encontrado: %%a
set "FOUND=1"
)
)
REM Búsqueda adicional por nombre parcial
if %FOUND%==0 (
for /f "tokens=2 delims==" %%a in ('wmic product where "name like '%%DOS%%'" get name /value 2^>nul') do (
echo Posible DOSBox encontrado: %%a
set "FOUND=1"
)
)
if %FOUND%==0 (
echo DOSBox NO está instalado en el sistema.
) else (
echo DOSBox está INSTALADO en el sistema.
)
pause
The problem is that it always says it is not installed when it is. How can I fix the algorithm so that it always gives the correct answer?
6