@ECHO OFF
SETLOCAL
@prompt :
%zero%@set zero=::&start "Zeroth instance" "cmd" /k "%~dpnx0"&pause&goto :eof
ECHO Maybe CHANGE TITLE...
pause
%first%@TITLE First Instance
%first%@set first=::&start "Second instance" cmd /C "%~dpnx0"&goto :waiting
ECHO got here-------------
pause
taskkill /F /FI "WINDOWTITLE eq First Instance"
taskkill /F /FI "WINDOWTITLE eq Administrator: First Instance"
:waiting
ECHO waiting...
PAUSE
exit
GOTO :EOF
Minor changes with lots of echoes and pauses...
If you run an additional session using tasklist /v|find /i "cmd"
you'll find that with the above code, the window title "Zeroth instance" will be changed to "First instance" when the appropriate pause
receives a response. Allowing 'Second instanceto reach the
taskkills will close the
Zeroth/First` window and if either new window reaches the exit statement, that instance is terminated. All fine and good and as expected. Using the additional session, you can see the various phases entered.
If you reintroduce the /b
switch, then THAT instance no longer has its own window, and hence the window that it hasn't got can't have a title. You can see this using the additional session. Now - getting that particular session to terminate is a bit of a game.... not sure start /b
plays nicely with an interactive batch...