@echo off %CMD With An Active Title(Simulate Thread) 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