I'm running the following script, but the errorlevel never seems to change from 0
Can anyone spot why it's not working as expected?
@echo OFF
set first=C:\dev\workspace\first
set second=C:\dev\workspace\second
set repos=%first% %second%
echo =====================================
echo First: %first%
echo Second: %second%
echo =====================================
echo.
echo.
for %%r in (%repos%) do (
echo %%r | findstr "first" > NUL
if errorlevel 0 (
echo Variable: %%r
echo ErrorLevel: %errorlevel%
echo "We found first"
echo.
)
echo %%r | findstr "second" > NUL
if errorlevel 0 (
echo Variable: %%r
echo ErrorLevel: %errorlevel%
echo "We found second"
echo.
)
)
This is the output I'm seeing:
C:\dev>new.bat
=====================================
First: C:\dev\workspace\first
Second: C:\dev\workspace\second
=====================================
Variable: C:\dev\workspace\first
ErrorLevel: 0
"We found first"
Variable: C:\dev\workspace\first
ErrorLevel: 0
"We found second"
Variable: C:\dev\workspace\second
ErrorLevel: 0
"We found first"
Variable: C:\dev\workspace\second
ErrorLevel: 0
"We found second"
Aucun commentaire:
Enregistrer un commentaire