execute/output in another terminal window

I want to write commands in terminal A that gets executed in terminal B.

If terminal B doesn't exist then terminal A opens a new window(terminal B) and then the code gets executed there.

If terminal B already exists, then no new window is opened and the code that was entered in terminal A gets executed/outputed in terminal B.

I dont get closer than this, which opens a new terminal every time

start cmd /k echo hello

Last edited on
Anyone?
Last edited on
Use a named pipe and events for communication between processes.
https://docs.microsoft.com/en-us/windows/win32/ipc/named-pipes
https://docs.microsoft.com/en-us/windows/win32/sync/event-objects

Then something like as pseudo code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
process A

If processB not exist {
    Create processB
    wait for event notification that processB has been created with read named pipe
}

establish write pipe to B

loop while command to process {
    send command to B using named pipe
}

process B

establish read pipe
send event notification that read pipe has beem established

loop forever {
    wait for pipe data
    read command from pipe
    execute command
}
Last edited on
Thank you both! :)
Registered users can post here. Sign in or register to post.