Solved

Stepping through a dos batch script in windows 7

Posted on 2014-12-09
8
2,143 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 53

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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.
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

822 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