Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I wish to create a bat file to create some basic task. When i run this it closes the window. I'm guessing it errors. How can i stop the bat closing the window so i can view the error.

mybat.bat:

echo cd /d d:
echo sencha create jsb -a http://my.local/ext/cutter/app/index.html -p app.jsb3
echo sencha build app.jsb3 -d .
share|improve this question
    
does it work? i mean, does it do what you wish it to do? is the only problem the fact that it closes? –  acolyte Jun 14 '12 at 17:14

3 Answers 3

Batch scripts will close the window itself after running it is not an indication of an error, if you put the word pause at the end of the script the script will stop and wait for you to press a key before proceeding

share|improve this answer

Two options:

  1. send output to a file (command > c:\output.log)

  2. Set a delay. In newer versions, it can be done with timeout \t xxx where xxx is the amount of seconds. In older versions, you can produce an effective delay with things like

    PING 127.0.0.1 -n 6

where each ping takes about one second... but hey, you don't need precission, right? :)

Both approaches avoid being frenzy on the pause button

share|improve this answer
    
+1 redirecting output –  Nixphoe Jun 20 '12 at 2:21

Run it from the commandline (cmd) and it will show you the output and not close when finished. The reason it is closing is because you are simply echoing (printing) stuff to the terminal. It isn't actually DOING anything. Take out all those echoes.

C:\>echo /?
Displays messages, or turns command-echoing on or off.

  ECHO [ON | OFF]
  ECHO [message]

Type ECHO without parameters to display the current echo setting.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.