Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Stepping through a dos batch script in windows 7

Posted on 2014-12-09
8
Medium Priority
?
3,340 Views
Last Modified: 2014-12-14
I know I could manually type pause after every line, but is there an easier way to step through a batch file to see what happens after each line?
0
Comment
8 Comments
 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 668 total points
ID: 40489312
Sadly no. There is no debug or step mode in cmd.exe.
0
 

Author Comment

by:BeGentleWithMe-INeedHelp
ID: 40489331
! : (
0
 
LVL 61

Accepted Solution

by:
HainKurt earned 336 total points
ID: 40489372
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 668 total points
ID: 40489417
Of course there should be some 3rd party tools able to emulate stepwise execution, but it requires some effort to do so and hence there is probably nothing for free.

Nowadays you should take the leap to switch to PowerShell.
0
 
LVL 59

Assisted Solution

by:Bill Prew
Bill Prew earned 332 total points
ID: 40489446
A couple of things you can do in a batch file though, certainly not a debugger, but sometimes can help.

(1) You can remove the ECHO OFF line if there is one (or change it to ECHO ON) and then when you run the BAT you will see each line executed echoed to STDOUT.  This take a little practice to read effectively, but can be helpful since it will show you some of the variables resolved to their actual values at runtime.

(2) If you have an idea of what you want to see and where you can add some ECHO commands after key logic and display helpful data like environment variables, or maybe do a DIR command if you are working with files, etc.

(3) When you run the BAT script, send it's output to a file rather than the console, and then you can browse it with an editor after it finishes, and search, etc.

(4) I have occasionally created a little debug subroutine and CALLed it from several locations along the code path.  Then it can display all useful info about variables, files, flags etc each file with headings.  Reduces the effort to adding displays along the way.

~bp
0
 
LVL 25

Assisted Solution

by:NVIT
NVIT earned 332 total points
ID: 40489485
Maybe Batch Compiler...
- Realtime debugging
- IDE for batch scripts
http://sourceforge.net/projects/batchcompiler/?source=directory
http://batchcompiler.sourceforge.net/
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 332 total points
ID: 40489850
If the batch file is simple, one line, affair without using ( ) to nest items or goto to move around you could probably get away with one batch to read the other using a for command, execute each of it's lines with a pause command between them?

Steve
0
 

Author Closing Comment

by:BeGentleWithMe-INeedHelp
ID: 40499101
Thanks guys!  Here's another question based on Qlemo's comment.  THANKS!  DUH!  Time to learn something new!

http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_28580586.html
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question