Command line PAUSE function not working

4

I'm experienceing a problem with a batch file command - when I run the program, I have a "PAUSE" command at the end of the batch file, however, the command window still automatically closes instantly, too quickly for me to see the results. Is there another way to prevent the command window from closing, or to somehow get the results? i.e, can a printed version be sent, inserted somewhere?

Background - I know squat about command lines, so please, if you can, any response please dumb down to novice level explanations. I am ultimately trying to determine versions of a MS Project file, and have used/followed this website instructions exactly, however the results won't display for me - the command window just dissapears instantly:

Microsoft website I used for instructions: A simple method to determine the version of an mpp file (MS Project plan file)

The text/commands within the batch file:

@ECHO OFF

REM  Version.bat

ECHO Filename: %1

ECHO.

ECHO -- CHECK FOR PROJECT VERSION --

strings %1 | findstr "[0-9],.,....,...." 2>NUL

ECHO Check the following list for the first one or two digits of the string above (xx,.,....,....)

ECHO List of xx (Product Name): 8 (98), 9 (2000), 10 (2002), 11 (2003), 12 (2007), 14 (2010)

ECHO. 

ECHO -- CHECK FOR MPP FILE VERSION --

strings %1 | findstr ".MPP" 2>NUL

ECHO Check the following list for the digit(s) at the end of the string above (...MPPxx)

ECHO List of xx (Product Name): 8 (98), 9 (2000/2002/2003), 12 (2007), 14 (2010)

ECHO.

PAUSE

user232864

Posted 2013-06-21T15:45:00.140

Reputation: 43

What OS are you using? I guess it is a flavor of windows but which one? – terdon – 2013-06-21T15:46:25.533

1I'm using windows XP - version 2002, service pack 3 – user232864 – 2013-06-21T15:48:12.297

Post your batch file contents – Travis – 2013-06-21T15:56:38.920

Here are the batch file contents, as described in the link (going to have to do this in 2 comment posts as it exceeds the max number of characters): @ECHO OFF REM Version.bat ECHO Filename: %1 ECHO. ECHO -- CHECK FOR PROJECT VERSION -- strings %1 | findstr "[0-9],.,....,...." 2>NUL ECHO Check the following list for the first one or two digits of the string above (xx,.,....,....) ECHO List of xx (Product Name): 8 (98), 9 (2000), 10 (2002), 11 – user232864 – 2013-06-21T16:00:50.087

(2003), 12 (2007), 14 (2010) ECHO. ECHO -- CHECK FOR MPP FILE VERSION -- strings %1 | findstr ".MPP" 2>NUL ECHO Check the following list for the digit(s) at the end of the string above (...MPPxx) ECHO List of xx (Product Name): 8 (98), 9 (2000/2002/2003), 12 (2007), 14 (2010) ECHO. PAUSE – user232864 – 2013-06-21T16:01:25.407

I’ll ask the “stupid question” –– are you sure that your batch file is running at all?  Try adding a command line like COPY NUL C:\TEMP\TESTFILE (specifying a directory that exists, that you have write permission for, and a file that doesn’t exist) to your script (say, right before the PAUSE), run it, and check whether the file was created.  If it was, ignore this comment and focus on the other answers.  If the file *wasn’t* created, try moving the COPY command to the beginning of the script.  If it still doesn’t create the file: bad news; you’re not even running your batch file. – Scott – 2013-06-21T17:24:02.860

1Scott - Thank you for the information above - all good to know. Turns out I didn't have the "strings" program installed, which was needed. Thanks for the assistance – user232864 – 2013-06-21T17:52:32.017

Answers

1

I suspect the file has an error. Try calling the batch file from an existing command window to see the message.

Most likely the problem is that the script is calling an external program called "strings" and according to the document you linked to this can be found here. In order for the batch file to be able to find it you should install it in the directory you are running it in, otherwise you will need to modify the PATH system environment variable or put it in a system directory.

James P

Posted 2013-06-21T15:45:00.140

Reputation: 9 542

Thank you - this worked. I can't believe I missed the "strings" program. Once downloaded it worked perfectly. Thank you! – user232864 – 2013-06-21T17:10:03.887

1

Wait

sec:

PING 127.0.0.1 -n <sec> >NUL

Wait 10 sec:

PING 127.0.0.1 -n 10 >NUL

Wait 10 sec:

powershell measure-command {sleep -s 10} ^| select TotalSeconds ^| Ft -Au

Wait 1/4 sec or 250 milliseconds:

powershell measure-command {sleep -m 250} ^| select TotalMilliseconds ^| Ft -Au

Pause

powershell:

powershell $host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')

var2:

powershell $host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') >NUL

var3:

powershell cmd /c pause ^| out-null

var4:

powershell [Console]::ReadKey()>NUL

var5:

powershell sleep

Pause command, batch/cmd:

cmd /c pause

STTR

Posted 2013-06-21T15:45:00.140

Reputation: 6 180

2Unfortunately I get the same result - still dissapears instantly – user232864 – 2013-06-21T16:07:22.500

@user232864 test powershell command and what do PING 127.0.0.1 -n 10 in cmd? At your Windows XP SP3? – STTR – 2013-06-21T16:22:27.207

2Thanks, tried the powershell at the end of the batch file, same result - the command window pops open for a second, then dissapears just as before. Not sure I understand the question "At your Windows XP SP3?" – user232864 – 2013-06-21T16:42:39.787

@user232864 From your question, I realized that you nuzhena delay and not pause. Now add) – STTR – 2013-06-21T16:48:40.860

2Thank you for the information above - all good to know. Turns out I didn't have the "strings" program installed, which was needed. Thanks for the assistance. – user232864 – 2013-06-21T17:11:11.297

0

If the former command is a batch file, the rest of your file is not executed. try a call before the previous commands/

kStarbe

Posted 2013-06-21T15:45:00.140

Reputation: 16

1You are repeating the other answer – yass – 2017-06-24T15:44:15.970