set /p msg=
if %msg%== y goto :y1
if %msg%== n goto :c1
:y1
cls
color 0a
I believe your error would be your beginning. Where you haveset /p msg=
, this would have %msg% equaling nothing which if your batch program starts with an error then it will close immediately.
You can have it equal anything you want for example if you want it to be blank you would have to have: set /p msg=" "
and in the Command Prompt it will just take your cursor to a blank line waiting for your input.
The most standard option is what command prompt uses to indicate a new line: set /p msg=" > "
I edited the code for you and you can change it as you wish... I cleaned up what it would look like a bit for you also
@echo off
echo input y or n
echo.
set /p "msg= > "
if "%msg%"=="y" goto :y1
if "%msg%"=="n" goto :c1
:y1
cls
color 0a
pause
Edit 1: fixed my quotes in the above code... the original placing wouldn't of done much with the above by itself but with additional code it may cause problems, when it comes to quotes and spaces batch is kinda picky
Side Note 1: if you want to have a timed pause instead of it waiting for a button press when it reaches pause, you can use the command timeout /t #
the # would be the number of seconds you want it to wait and you can also press any button to have it be like the pause button... now just like how the pause button has the "Press any key to continue..." phrase so with timeout it has something like this but do not quote me on this "Press any key to continue or wait #..." you can hide the phrases from appearing but using either of these code lines: pause >nul
or timeout /t # >nul