I have a batch file with for example
cd c:\test
But there is more then this in the batch, it’s just an example.
So, if I call it from explorer, I see a cmd window for short time and then it will be closed. How can I avoid this?
I tried to call PAUSE at the end, but for me it’s cheating 🙂
UPD:
just imagine, I’m lazy and need to call different batches from different directories very often. That’s why I wanted to have my batches in just one diretory calling another batches, but I also want to see results after execution
I presume you are double clicking on the batch file from within Windows Explorer (or else right clicking and selecting open). If so, then you are getting the expected behavior. When you double click on any executable, the window should close once the executable completes.
Putting a PAUSE before the end is the appropriate technique to allow you to see the results before the Window closes. It is not cheating.
If you want the command window to remain open after the batch file terminates, then you can use an appropriately configured shortcut.
Assume the batch file is C:\MyPath\TEST.BAT. You create a shortcut for it, right mouse click on the shortcut, and edit properties. Modify the Target: as follows:
If you double click on the shortcut, TEST.BAT will run and the command window will remain open after it terminates. But now the command window will remain open indefinitely until you explicitly close it.