当前位置:DOS资源站资料中心批处理教程 → 标题动态变化的批处理

标题动态变化的批处理

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2008-5-31 21:53:52

@echo off        %CMD With An Active Title(Simulate Thread)        dos.net">s11ss@www.cn-dos.net 2008-4-17%

if "%1" equ "-title" call :PrintTitle "%comspec%"
start /b "NewThread" %0 -title
tasklist|findstr "\<cmd.exe\>">"%tmp%\t4.17"

setlocal enabledelayedexpansion
for /f "delims=" %%a in ('echo exit^|cmd') do (
        set/a n+=1
        if !n! leq 2 echo %%a
)
echo.
endlocal

:RunCommand
set/p COMMAND=%cd%^>
if "%COMMAND%"=="" (
        goto :RunCommand
) else (
        if "%COMMAND%"=="exit" (
                for /f "usebackq tokens=2" %%a in ("%tmp%\t4.17") do set t=%%a
                del "%tmp%\t4.17"
                call taskkill /f /pid %%t%% >nul
        )
)
call %COMMAND%
echo.
set "COMMAND="
goto :RunCommand

exit/b


:PrintTitle
set s'=%~1&set/a n'=0,t'=n'+1
:ptloop
call set o'=%%s':~%n'%,1%%&if "%o'%" equ "" goto :PrintTitle
call title %%s':~0,%t'%%%&set/a n'+=1,t'=n'+1&ping 127.1 -n 1 >nul&goto :ptloop
 

再来个简单点的

@echo off&mode con lines=5
:begin
set str=2008北京奥运,我们正在自豪地期盼你的到来!
for /l %%i in (1,1,23) do (
    setlocal enabledelayedexpansion
    title !str:~,%%i!
    ping /n 1 127.1>nul
    endlocal
)
goto begin