Development, Free Tools

CommandThreader – Execute any list of commands threaded into as many threads as needed (Updated)

Written in 2009 for the Windows versions of the time. Check that the tool or steps still suit your environment before using them.

CommandThreader by Shaun Vermaak is a command line tool that makes it possible to execute any list of commands threaded into as many threads as needed.

03/05/2009 - Fixed thread IDs
24/11/2008 - Added line numbers
03/11/2008 - Minor bug fixes

Publishers website: https://www.ittelligence.com
ITtelligence mirror: CommandThreader.zip (7.05 Kb)

Usage: CommandThreader.exe NUMBER_OF_THREADS INPUT_FILE.TXT
Lines in INPUT_FILE.TXT must be in format COMMAND|ARGUMENT|WORKING_DIRECTORY|HIDDEN|TIMEOUT

Example: PSEXEC.exe|\\192.168.0.1 -c -d -f Program.exe||True|1000

How to Use ItLink to this section

The current download is version 2.0. Its syntax differs from the one above: the input file comes first and each line has six fields. It needs .NET Framework 4.5.

CommandThreader.exe INPUT_FILE.TXT [NUMBER_OF_THREADS] [SKIPTOLINE]
CommandThreader.exe Commands.txt 10
CommandThreader.exe Commands.txt 10 150

Parameter

Meaning

INPUT_FILE.TXT

Text file with one command per line. Blank lines are ignored.

NUMBER_OF_THREADS

How many commands run at the same time. Default 20.

SKIPTOLINE

Start at this command, counting non-blank lines. Default 1.

Each line must be in the format COMMAND|ARGUMENTS|WORKING_DIRECTORY|HIDDEN|WAIT|TIMEOUT, for example:

PSEXEC.exe|\\192.168.0.1 -c -d -f Program.exe||False|True|60

Field

Meaning

COMMAND

Program to run.

ARGUMENTS

Its arguments.

WORKING_DIRECTORY

Read but not used; commands always start in the current folder.

HIDDEN

True or False.

WAIT

True to wait for the command to finish, which keeps its thread busy. False starts it and moves on.

TIMEOUT

Seconds before the command is killed. 0 means no limit.

For each command it prints (+) when it starts, (=) with the ReturnCode when it ends, and (-) when the thread is free. ReturnCode is the exit code, the process ID when WAIT is False, or -1 if the command could not start. The output of the commands themselves is not shown. The download includes DummyApp.exe and DummyInput.txt for testing.

Note: lines in the old five-field format from version 1 do not parse correctly in version 2; they run without waiting, so all commands start at once. TIMEOUT only works for values below 60, because the code compares the seconds part of the elapsed time rather than the total.

CommandThreader version history

  1. June 15, 2017

    • Input file lines add a wait-for-exit flag and a maximum run time before the process is killed
    • Usage now takes the input file first, then the thread count
  2. May 3, 2009

    • Fixed thread IDs (03/05/2009)
    • Added line numbers (24/11/2008)
    • Minor bug fixes (03/11/2008)

Posted on

No comments yet

Comments are moderated and appear once approved.