雪风 发表于 2009-5-19 00:07:25

传说中的批处理

{:4_91:}

@echo off
setlocal enabledelayedexpansion
    (set Result=)
    for /L %%I in (2147483647, -33554428, 0) do (
      call :ErrMake %%I
      call :ErrFind > nul
      echo !ErrFind!.
      REM if"!ErrFind!" neq "%%I" echo OOPS.& exit /b
    )
endlocal
call:_& echo All Done.& pause
goto:eof

:ErrFind
(if "!Result!"=="" set Result=%0&set Result=!Result:~1!&(if not errorlevel 1 set !Result!=0&set Result=&goto:eof)&set H=2147483647&(if errorlevel !H! set !Result!=!H!&set Result=&goto:eof)&set L=0)&set/a A=H/2+L/2&echo H:!H! A:!A! L:!L!&(if errorlevel !A! ((if !L!==!A! set/a A+=1&(if not errorlevel !A! set A=!L!)&set !Result!=!A!&set Result=&goto:eof)&set L=!A!)else set H=!A!)&goto%0

:ErrMake X
if /i "%~2"=="norm" (set errorlevel=)
if /i "%~2"=="both" (set errorlevel=%~1)
if /i "%~2"=="user" (
    cd.\&(set errorlevel=& if errorlevel 1 exit /b %~1
    call:_
    echo It is recognizable that a variable errorlevel
    echo have been manipulated, value is %errorlevel%.
    echo.
    echo "%~nx0" is ready to create the exit-code %~1,
    echo Please make a choice, 1...3:
    echo.
    echo 1: As requested, create an ERRORLEVEL %~1
    echo.
    echo 2: Also set the synthetic errorlevel variable
    echo.
    echo 3: Normalize/restore the synthetic errorlevel
    echo    so it is following the real DOS ERRORLEVEL
    echo.& (set /p errorlevel=?: )
    if "!errorlevel!"=="3" set errorlevel=&exit /b %~1
    if "!errorlevel!"=="2" (set errorlevel=%~1) else (
    set errorlevel=%errorlevel%))
)
exit /b %~1
:_
for %%_ in (________________) do (echo %%_%%_%%_%%_%%_)



批处理爱好者可以自己研究下非常强悍!!!

ansinjay 发表于 2009-5-20 04:49:18

······好久没看见雪风哥发贴了,难得呀,我在论坛找雪风大哥以前的教程,好多都是以前博客去下载的,但那个博客似乎不存在了,所以我求雪风哥以前发布过的教程,比如修改鸽子那个14课,我在论坛里面找了好久才找到了6课,是只出了6课还是什么原因我不清楚,还有就是那个修改鸽子为专用上线教程,我不想自己的DAT被别人拿去乱用,你的那个博客我去了,但好像已经不存在,打不开了,哪么多经典的教程就那样付之东流了,好可惜,所以在这里,我求雪风大哥以前发布过的所有教程,只要是你出的,不管什么,我都要,希望雪风大哥给个下载地址谢谢,黑狼和雪风我是永远支持的@!!!!!我的邮箱:kofzjf@tom.com
页: [1]
查看完整版本: 传说中的批处理