Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file help  (Read 3186 times)

0 Members and 1 Guest are viewing this topic.

Jujimufu

  • Guest
Batch file help
« on: December 18, 2007, 01:49:54 AM »
This has probably been asked before, but every time I run a batch file with the code
@echo off
echo "Message Here"

the command window comes up, but only stays on the screen for a fraction of a second. I'm pretty sure that it's meant to stay on, without disappearing. Is there any way to fix this?

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch file help
« Reply #1 on: December 18, 2007, 07:37:59 AM »
If you run your batch file within the command window, this problem does not occur. If you run from Windows Explorer or a shortcut add a pause statement to the end of your file:

Code: [Select]
@echo off
echo "Message Here"
pause

There are other ways to do this, but some are more complicated than their worth.

 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

S_R_S5

  • Guest
Re: Batch file help
« Reply #2 on: December 19, 2007, 06:47:41 PM »
You need to add "Pause" at the end.
also if you are going to have several echo's in 1 batch file or if you want a (y/n) you can use "cls".

To make it so it doesnt say "press any key to continue" type ">nul" at the end of pause.

Code: [Select]
@echo of
echo blah blah
echo.
echo press enter to continue.
pause >nul
cls
echo blah blah
pause >nul

good luck,
S_R_S