@echo off rem get_cmd_windowtitles for /f "tokens=2,9*" %%a in ( 'tasklist /v ^| findstr /i cmd.exe' ) do ( echo:%%a %%c>>"%temp%\title01.tmp" ) rem end get_cmd_windowtitles rem change title to something else set "newtitle=%username%@%computername%" echo: echo:NEWTITLE: %newtitle% title %newtitle% rem get_newtitle_window for /f "tokens=2,9*" %%a in ( 'tasklist /v ^| findstr /i "%newtitle%"' ) do ( echo:%%a %%c>>"%temp%\title02.tmp" ) rem end get_newtitle_window rem get_org_windowtitle for /f %%a in ( 'findstr /i "%newtitle%" "%temp%\title02.tmp"' ) do ( for /f "tokens=1*" %%i in ( 'findstr /i %%a "%temp%\title01.tmp"' ) do ( set "orgtitle=%%j" ) ) rem end get_org_windowtitle rem change title to original title echo: echo:ORGTITLE: %orgtitle% title %orgtitle% pause rem remove temp files if exist "%temp%\title*.tmp" del "%temp%\title*.tmp"