is it possible to sync two cmd windows?
there is two cmd windows open.
when i typing in window1 and press enter.
the message will popup in window2.
how to do that
two batch windows sync
Moderator: DosItHelp
Re: two batch windows sync
There is no real good possibility for such an intention. The first batch have to write to a file and the second batch have to read this file using an endless loop.
1.bat
2.bat
1.bat
Code: Select all
@echo off &setlocal
type nul>"data.txt"
echo Enter your text:
echo.
:loop
set "input="
set /p "input="
>>"data.txt" echo.%input%
goto loop
2.bat
Code: Select all
@echo off &setlocal
set /a n1=0
set /a n2=0
:loop
if not exist "data.txt" (
cls
set /a n1=0
set /a n2=0
ping -n 2 localhost>nul
goto loop
)
for /f "delims=: tokens=1*" %%a in ('findstr /n /r /c:"^" "data.txt"') do (
set /a n1=%%a
set "line=%%b"
call :process
)
ping -n 2 localhost>nul&goto loop
goto:eof
:process
if %n1% gtr %n2% (
set /a n2=%n1%
echo.%line%
)
goto :eof