24

When the program is over, I want it to say "Press any key to continue..." so I can scroll thru the output.

6 Answers 6

45

I believe you are looking for the command "pause". It should ask you to press any key.

You can even appear to change the prompt. Instead of just using the pause statement, you can:

echo "Your message here" pause > nul 

This gets rid of the original pause message and inserts yours.

Jacob

Sign up to request clarification or add additional context in comments.

2 Comments

That checkbox hasn't been there since the old days of Windows 98.
Ok, now I am feeling old. Good catch.
4

In Windows/DOS batch files:

pause 

This prints a nice Press any key to continue . . . message

Or, if you don't want to show anything message, do this instead:

pause >nul 

Comments

2

Create a shortcut to your batch file.

Right click on the file and select "Properties".

In the tab "Shortcut" is the target, something like this:

C:\folder\file.bat

Change it by this one:

C:\Windows\System32\cmd.exe /K "C:\folder\file.bat"

where "C:\Windows\System32" is the folder where cmd.exe is located, which may be another according to your Windows installation.

Then you can run the shortcut.

Comments

1

A part of me says that "pause" in the batch file should also do the trick. But also give the /K switch a try as well.

HTH

Comments

1

If you want the console to remain open, you can add the following at the end of batch file -

call cmd

This will open console with in the same one with all your environment variables set in your batch file and you can work in it.

Comments

0

you need to type in pause, which when you make it to the end, it should say

Press any key to continue . . .

but only if you put it at the end, because if you don't, it will pause it at the place you put it. Don't try '/k' because it doesn't work

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.