Batch file command PAUSE does not work
I was having issues even on echo... assuming it was caused by long batch file... Pause was executing but it was not pausing, it was almost like that it was pressing a key after Pause was executed.
Tried suggested solutions above; none worked.
So just for future reference, here is what I did:
Basically just "pause > nul && pause > nul"; works every time.
@echo off
CALL :ForcePause "Press any key to resume."
ECHO.
ECHO Hello World!
ECHO.
CALL :ForcePause "Press any key to exit."
EXIT
REM You can remove echo if you don't want to pass custom string for pause
:ForcePause
echo %~1
pause > nul && pause > nul
GOTO :EOF
Does the last command before pause execute successfully? Mind sharing your script - at least last few commands?
Alternatively, since you seem to be using Windows7, try Timeout command and see if that is working.
If the last command fails pause won't work.
You can fix it by putting "call" behind the command you are running (whatever command is before the pause) then the pause will work.
So for example I had a phpunit batch file that looked like this:
phpunit tests/sometests.php
pause
When phpunit failed it just exited without pausing. Changing it to this made it pause correctly:
call phpunit tests/sometests.php
pause