Click here to Skip to main content
13,250,182 members (56,373 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 12 Jun 2014

Program Error Reports with Visuals from .bat Files (Win7)

, 12 Jun 2014
Rate this:
Please Sign up or sign in to vote.
Program return values inspected by .bat files with visual feedback

image from wikipedia : Ascii Art

<-- The Command Line Is Awesome!

This tip/trick is basically a short batch script example of a friend for the programmer who has to use other peoples tools, batches, programs in order to confirm whether everything went well with the external tools. :)

This revolves basically around inspecting what a .bat file (or possibly .exe files too) returns as the value after it has been run, (i.e., whether it succeeds or not) then reporting about any possible errors or successes in a visual way, so that any errors that the user of a batch script file could normally miss, won't be missed. :)


Why Use This?

Because in everyday work around computers, there are multiple EXEfiles, batch files, etc. that might come in play, some regularly, some maybe not so regularly, and this is a fun trick how to inspect whether those batch files did their job properly or not. :) Mostly, this is useful for people that use some set of external batch files to do some operations, but in case you are not one of those, it can still be a fun experience to download the articles sample and try it out on your Windows machine. :)

Using the Code

usage: download the sample ( follow the next instructions:
1. create a do_something_cool.bat that's empty
2. create another .bat file with the below script copy pasted in, save it as whatever.bat
3. then run whatever.bat and see what happens! ...or you can just download the sample ;)

Here's the body of the whole script:

@echo off
echo ---------------------------------------------------------------
echo .
echo .
echo .
echo .
echo ---------------------------------------------------------------

CMD /c do_something_cool.bat
echo ---------------------------------------------------------------
echo .
echo .
echo . That important thing went great! Happy time! :)
echo .
echo .
echo ---------------------------------------------------------------
mshta "javascript:var sh=new ActiveXObject( 'WScript.Shell' ); sh.Popup( 'THE THING SUCCEEDED!', 0, 'do_something_cool.bat', 64 );close()"
echo ---------------------------------------------------------------
echo .
echo .
echo . Something went wrong bro! You gotta meditate on this!
echo .
echo . Write exit to confirm and close after you've fixed it ;)
echo .
echo .
echo ---------------------------------------------------------------
mshta "javascript:var sh=new ActiveXObject( 'WScript.Shell' ); sh.Popup( 'THE THING FAILED, PLEASE FIX!', 0, 'do_something_cool.bat', 64 );close()"
cmd /K ping -n 1 -w 1000 > nul

Points of Interest

The mshta JavaScript command line feed opens up some interesting opportunities for various smart snippets on Windows, that could be looked into more. :) Also, the %ERRORLEVEL% is an interesting builtin.


  • Version 0.01 uploaded, 12th of June 2014


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Jani Mäkinen
Software Developer (Senior) Muvika Ltd
Finland Finland
I write minimal and efficient no BS code. More at

Specialties: Cross-platform tech, C, C++, Game Programming & Design.

I was born in the middle of Finland into a small farming town. Moved to Helsinki, then to Germany and am now back in Helsinki programming in the game industry Smile | :)

If you're a junior programmer and reading this, keep hacking, the rewards of our craft manifest in the later stages, and it does get good Smile | :)

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171114.1 | Last Updated 12 Jun 2014
Article Copyright 2014 by Jani Mäkinen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid