Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Wrong errorlevel [batch script]

$
0
0

Hello I have a weird problem...

I have a batch script which is installing some software silently... and after every installation it check an error code... well it detect that something goes wrong, but it didin`t print right error code...

Here is my batch script:

if not "%XXX:~15%" == "~15" (
if "%XXX:~15%" == "A" (
if not exist "XXX*.exe" (
@echo Installation package XXX wasn`t found!
exit /B 1
)

@echo Installing XXX!
for /F "delims=" %%a in ('dir /b "XXX*.exe"') do start "" /wait "%%a" /S /M=_config.config
@if ERRORLEVEL 1 (
@echo ERROR %ERRORLEVEL%
exit /B %ERRORLEVEL%
)
) else (
if "%XXX:~15%" == "" (
@echo Installation of XXX is DISABLED!
) else (
   @echo ERR: Unknown option for XXX
exit /B 1
)
)
) else (
@echo ERR: option XXX_on wasn't found
exit /B 1
)

I have like 10 these block in one batch file... what is weird on this is that if I have just one that block in batch file... it works well... but if I have all of them in one batch file... it detect error code bigger than 0 but it print ERROR 0....

Can you help me pls? Thank you so much...


Viewing all articles
Browse latest Browse all 12583

Trending Articles