Every time there is an error with my code and I want to better understand what I did wrong, I turn @echo on
. When your batch file crashes though, it obviously isn't able to display the issues since the command prompt screen crashes. Is there a way to view why it crashed, or at least showing there was a undefined variable or something along those lines?
Asked
Active
Viewed 2,134 times
0

Victor Chavez
- 59
- 7
-
@KenWhite I believe I miss understood what crash means. I simply mean that the window closes. For example if you do ```if %variable% == 1 goto function```, and either variable isn't defined or function is not in your code, then the window closes. – Victor Chavez Dec 02 '20 at 22:43
1 Answers
3
If you open the command prompt manually (win-R and type cmd) and cd over to the .bat file location and run it there instead of double clicking from the file explorer, the command prompt window wont close when .bat finishes and you can see the error message

ComplexityAverse
- 104
- 3
-
1When you use the point-click-and-giggle method of executing a batch, the batch window will often close if a syntax-error is found. You should instead [open a 'command prompt'](https://www.howtogeek.com/235101/ ) and run your batch from there so that the window remains open and any error message will be displayed. – Magoo Dec 03 '20 at 02:03