Q:

BATCH program crashes after goto command

This code is part of a chat program that I am currently working on.  The 'else' part of my program is the one that doesn't work. The program quits instead of going to :home
:join
cls
if not exist "C:/Users/Public/room.cmd" (
echo No room has been found.
echo.
set /p choiceretry=Do you want to retry? y/n 
if "%choiceretry%"=="y" goto join
if "%choiceretry%"=="n" goto home
) else (
cls
"C:/Users/Public/room.cmd"
echo A room has been found. 
pause >nul
echo Joining
set roomjoined=1
echo %roomjoined%
goto home
)

:home
echo this finally works
pause

I have tried changing the code several times starting from 'echo Joining'
Anyone know why cmd quits?...
:) :) :)
Thanks in advance

A:

The problem is the way you run room.cmd; you must use call to return from it:
call "C:/Users/Public/room.cmd"

Otherwise, execution will not return from room.cmd to the original batch file that ran it.
Hint: Consider to use choice instead of set /P for Y/N decisions.

