EV: DOS batch commands
echo .
echo "my comments"
echo %windir% 显示windows variables/环境变量
call Batch1.bat
if %ERRORLEVEL% NEQ 0 goto failed
echo ...Completed Batch1, %ERRORLEVEL%
call Batch2.bat
if %ERRORLEVEL% NEQ 0 goto failed
echo ...Completed Batch2, %ERRORLEVEL%
Call Batch3.bat
if %ERRORLEVEL% NEQ 0 goto failed
echo ...Completed Batch3, %ERRORLEVEL%
goto end
:failed
echo ....ERROR Please check logs for further details, %ERRORLEVEL%
:end
endlocal
if ""%1"" == """" goto startsql
echo Waiting for %1 seconds...
sleep %1
:startsql
echo Starting sql server service...
net start MSSQL$SQL2012
pause
------------end of startsql.bat-------------
========================================
REM
In a batch file REM at the start of a line signifies a comment or REMARK, alternatively adding :: at the start of a line has a similar effect.
For example:
@ECHO OFF
::
:: First comment
REM Second comment
REM
Echo Hello REM This remark is displayed by echo
Echo Hello & REM This remark is ignored by echo
Copy work.xls backup.xls &:: We backed up the file
Although you can use Rem without a comment to add vertical spacing to a batch file, you can also use completely blank lines. The blank lines are ignored when processing the batch program.
The double-colon is not documented as a comment command, it is a special case of a label that acts as a comment.
An alternative approach is to use plain text and a goto command to jump execution past the comments:
@Echo OFF Goto :START
Description can go here which can even include - | > characters :START