Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Batch file help: Return error level except errorlevel 3010

May 6, 2008 5:55PM PDT

i was trying to write a batch file that installs a program, and when there is an error return the error level - except when it has errorlevel 3010


@echo off

:SP2
Start /wait C:\SQLInstall\SP2\SQLServer2005SP2-KB921896-x86-ENU.exe /quiet /allinstances
IF (%ERRORLEVEL% == 0) goto OK
else IF (%ERRORLEVEL% == 3010) goto Restart
else goto ERROR_SP2Install

ShockedK
echo SP2 Installation finished.
echo Log file for SQL 2005 SP2:
echo C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\Log\Hotfix\Summary.txt
echo.

:Restart
echo SP2 Installation finished. Restart required.
echo Log file for SQL 2005 SP2:
echo C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\Log\Hotfix\Summary.txt
echo.

:ERROR_SP2Install
echo Error occurs when installating SQL server 2005 SP2. Error level: %ERRORLEVEL%
echo Log file for SQL 2005 SP2:
echo C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\Log\Hotfix\Summary.txt

however this doesnt works. Could anyone please help me to come up with a way that I can get the errorlevel when there is an error except when it was errorlevel 3010?

Discussion is locked