How do I debug .bat and .cmd files.
Question
Friday, December 3, 2010 12:04 PM
In my main .BAT program file, I am calling multiple .bat and .cmd files but getting error at end. So I am searching tool who allowed me to debug. I tried ECHO OFF and error.txt out file options too, but those did not worked fully. And to have exacts felling debugging to check the runtime variable values and need a tool. Please help me to resolve this problem.
Thanks.
Anil
All replies (9)
Friday, December 3, 2010 4:04 PM
I think you are on the right track with the ECHO OFF and logging file. I don't know of any tools to do this, can you pelase describe a bit more why you are doing this, and what errors you are receiving?
Ed Hickey http://blogs.msdn.com/b/edhickey/archive/2010/04/21/how-to-post-effectively-in-forums.aspx
Tuesday, December 7, 2010 9:55 AM
Thanks Ed,
In my application, I have different .bat and .cmd files, which does different actions like copy, register, deleted etc on different files like dll, cpp etc. when I run master .BAT file, I am getting 'PATH not Found' error message. So to debug this problem, I tired to run each .bat and .cmd file separately but because of , output of one file (i.e. .BAT and .CMD) is input for second file I start getting different errors. Again this path is created at run time and to check that path, I am searching for tool.
Thanks
Anil
Tuesday, December 7, 2010 8:53 PM
You will get more information for debugging using filemon or procmon (filter for "name not found error" for the path you are operating on) The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP
Wednesday, December 8, 2010 5:59 AM
How could this tool help me? It is just monitoring the system processes.
Anil
Wednesday, December 8, 2010 8:24 AM
Try removing ‘@’ from the beginning of lines. It prevents displaying of commands. Then start BAT files and see on which line the error “PATH not found” occurs.
Wednesday, December 8, 2010 9:02 AM
Sorry Viorel, I did not get your point. Could you please explain it in detail?
Thanks,
Anil
Wednesday, December 8, 2010 9:11 AM
Sorry Viorel, I did not get your point. Could you please explain it in detail?
Thanks,
Anil
Lines that are prefixed by ‘@’ character are not displayed when BAT file is running from command line, even if file contains ECHO ON. So remove them to see how the file is executed.
Wednesday, December 8, 2010 9:26 AM
Hi Viorel,
I am getting 'path not found' error for below line -
%BUILDSCRIPTS%\utils\pkzip25 -extract=all -overwrite=all -directories %PRE_KIT_DIR%\SrcFiles\NANDGS1_INTPUT_LOC% %PRE_KIT_DIR%\SrcFiles\NAND_Flash_Working\
There is no <'@'> character preset. I want to know the values of variable that used to from this path.
Anil
Wednesday, December 8, 2010 9:39 AM
Try putting quotes around the paths. It is possible that the environment variables contain spaces and this is throwing everything off. To check the value of the variables you can use either set or echo. So in your command window either use set without any parameters to get list of all variables set, or try echo for all your named variables to make sure they contain valid paths.
Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/