Create a batch file that prompts user to press any key to exit

I created a batch file however, I am want a command that will prompt the user to echo "Press any key to exit" and that once the key is entered it will exit.
gm5522Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve KnightIT ConsultancyCommented:
@echo off
rem the rest of your batch
pause
cls
exit

Is that what you mean?
Steve
0
Steve KnightIT ConsultancyCommented:
If you want it to specifically say that:

@echo off
echo Press any key to exit
pause > nul
cls
exit
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Normally, you would just add the pause command at the end of your batch. Nothing else is needed.
0
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Steve KnightIT ConsultancyCommented:
Agreed.... the pause is the important bit :-)
0
t0t0Commented:
All you need to add to your code are the following three lines:

   ECHO Press any key to exit
   PAUSE >NUL
   EXIT /B



You don't need these lines:

   @echo off
   cls

And be careful with the EXIT command because without the '/B' switch, EXIT will close down your DOS session too.
 
0
Steve KnightIT ConsultancyCommented:
toto you are just being pedantic now :-) I imagine the guy just wanted to know of pause... and in general at least someone running a batch file from a cmd window wouldn't need a press any key to exit...  the cls and exit is from older versions? of windows that would not close the window if something showed on the screen.... habit but not normally needed now as you say.
0
t0t0Commented:
I don't suppose the asker knows how to split points between contributors....

So, he went with the CLS then?....
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.