Solved

Stepping through a dos batch script in windows 7

Posted on 2014-12-09
8
2,285 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 69

Assisted Solution

by:Qlemo
Qlemo earned 167 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 51

Accepted Solution

by:
HainKurt earned 84 total points
ID: 40489372
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 69

Assisted Solution

by:Qlemo
Qlemo earned 167 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 54

Assisted Solution

by:Bill Prew
Bill Prew earned 83 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 24

Assisted Solution

by:NVIT
NVIT earned 83 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 83 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

821 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