Multithreaded batch execution utility.

Description: This project largely came about after I got my hands on a great set of command line tools for windows called PsTools. I was putting together some very useful batch scripts for use in the lab and driving them with a for loop and a delimited text host file. Managing all the batch and host files started to become burdensome, especially with some systems needing different credentials than other. Another problem I was having was keeping track of the systems that had the scripts successfully run on them. For instance I did not want to do FireFox upgrades while the browser was active on a system and would have to come back and do it later. I had also figured it would be pretty easy to have several of these commands running at the same time, reducing the time needed to traverse a host list.

I was very pleased with the solution. After some research and experimentation I found out how to launch processes with inherited standard output handles. This allowed my application to read the output from the batch execution and store it. I could also easily track the exit code allowing me to store success or failure and manipulate it from inside the batch file.

I tied the whole application into a database and could easily pass important information into the batch files using command line parameters. I can also easily control which systems to run a command on by making a selection in the application or using the database to build different run tables. The finishing touch was allowing the program to save the host list and batch to run. This allowed me to easily track what systems still needed to have the commands run on it. In the future it would be nice to add a scheduling component that will have the program automatically run commands at a later time and/or until the command successfully executes on all systems in the host list.

Tools: Visual C++ Pro, MFC.

Topics: MFC Document/View architecture, splitter windows, using pipes for IPC, process spawning, inherited handles, ODBC, List and Tree views.

Here is a screen shot of the application running a ping sweep of the lab. The 8 batch files are running in the background launched using a hidden window. Note that the window can be dynamically resized with controls automatically adjusting. Also the command tree, host list and command output areas are all using splitter windows, allowing their size to be adjusted as well.

MultiBatch Image 1

Here you can see some of the scripts related to launching remote desktop sessions. I found batch scripting to have a surprising amount of functionality and can let you do some fairly complex actions.

MultiBatch Image 2

Here is a screen shot of the project in Visual Studio. There are two executables, the main interface and a cradle application that is launched for each instance of the batch file. The cradle communicates with the main application using pipes, transmitting the command output back.

MultiBatch Image 3

Please contact me if you are interested in acquiring a copy of the program, seeing the source code, or have any comments.

Back to the projects page.