0

I am trying to debug a complex CMD batch script. Is there a way to run it one statement at a time, like how some IDEs allow you to run your program step-by-step?

In addition, I would like to log everything (each statement and its result after evaluation) to a log file.

Baur
  • 111
  • 1

1 Answers1

1

This works for all commands (I managed to test in short notice) except for goto and for, as well as commands extending multiple lines.

It is a draft and can be improved.

@echo off
for /f "delims== tokens=*" %%a in (target.bat) do (
echo.
echo %%a
echo %%a >> log.txt
pause
%%a
)

It tells you what command its about to run and puts it into the log.txt file. Then upon pressing a key it runs the command.

If some one can improve this please tell me how.

Hope this helped. Mona.

Monacraft
  • 6,510
  • 2
  • 17
  • 29