Skip to content

Task Runner is a simple Windows command line tool (.NET/C#) to execute several tasks controlled by XML config files, such as deleting files, deleting registry entries, write logfile entries or execute programs.

License

Notifications You must be signed in to change notification settings

rabanti-github/TaskRunner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TaskRunner

Task Runner is a simple Windows command line tool to execute several tasks controlled by XML config files, such as deleting files, terminate processes, deleting registry entries, write logfile entries or execute programs.

Please have a look at the Wiki for more information.

Purpose

Preamble

It was a nice Sunday in July 2017 when I suddenly noticed that <Insert your favorite Foe Application> changed something after the last update. The <FoeApp> hooked itself into the Windows auto-start and the option to disable this seemed to be broken. The only way to prevent the auto-start of <FoeApp> was to use one of the obvious Windows optimization utilities or to delete an entry in the Windows registry under HKCU\Software\Microsoft\Windows\CurrentVersion\Run. However, <FoeApp> did not care! After starting the app, the registry entry was there again! After fiddling around, I decided to write a small utility to delete this registry entry on each logoff. Moreover, while developing, I added further features to my utility, because there are enough <FoeApps> out there with various misbehaviors.

How to use

TaskRunner is meant to be added as a task in the Windows task scheduler. The advantage of using this utility instead of the task scheduler directly is that the configuration of TaskRunner can be done simply by altering the XML code of the configuration. Furthermore, the configuration can contain an arbitrary number of Sub-Tasks.

The TaskRunner has only to be registered once in the task scheduler with the proper arguments. E.g.: TaskRuner.exe --run C:/tasks/config.xml --log C:/tasks/logfile.log

All Sub-Tasks are now defined in the file C:/tasks/config.xml. Furthermore, the result of each task execution will be logged into C:/tasks/logfile.log. The task in the Windows Task Scheduler does not have to be altered anymore.

The utility can be used of course as a standalone application, e.g., in combination with a BAT file to run repeating tasks just by double-clicking on the BAT file.

Prerequisites

TaskRunner was written in C# and relies on Windows functionalities. The only prerequisites are:

  • A Windows System (7 / 8.x / 10)
  • An installed .NET Framework (at least .NET 4.5)

Furthermore, you need the following knowledge when using TaskRunner:

  • Basic knowledge of XML (tags, attributes, escaping, etc.)
  • Basic knowledge how to run a command line application
  • Basic knowledge about the Windows task scheduler or the local group policy editor (gpedit.msc) if you want to use TaskRunner as proxy app

Usage

Normal Usage:

TaskRunner.exe -r [path to configuration] <options>

Generation of example files of the configuration:

TaskRunner.exe -e

Generation of markdown files of the documentation:

TaskRunner.exe -m

Path to the configuration: A relative or absolute path to the configuration as XML file

Parameter Handling

The flag -p or --param delivers a temporary parameter to the TaskRunner. The parameter is only valid during the execution of the loaded task.

Syntax: -p|--param:<data type>:<param name>:<param value>

The parameter flag contains 3 or 4 parts, delimited by colons:

  • 1: Flag Identifier (-p or --param)
  • 2: (Optional) Data Type. Valid values are 's' for string, 'b' for boolean and 'n' for number (double). If this part is omitted, the value will be handled as string
  • 3: Parameter Name (unique string, without spaces or colons)
  • 4: Parameter Value (The value will be parsed to boolean or double in case of the data types 'b' or 'n')

Examples:

-p:n:NUMBER_OF_FILES:8

--param:b:MATCH:true

--param:NAME:machine1

-p:s:NAME:"Name with spaces"

--param:COMMENT:'Other quotes are also OK'

Flags / Options

-r | --run: Runs a task defined in the subsequent config file (path)

-e | --example: Runs the demo command and generates example configurations in the program folder

-o | --output: Enables the output mode. The results of the task will be displayed in the shell (cmd)

-s | --stop: The task runner stops after an error. Otherwise, all sub-tasks are executed until the end of the configuration

-l | --log: Enables logging. After the flag, a valid path (absolute or relative) to a logfile must be defined

-h | --help: Shows the program help

-d | --docs: Shows the menu with the documentation

-m | --markdown: Saves the documentation as markdown files

Possible Tasks

Please look at the demo files and into the Wiki for all parameters and a detailed description of the configuration.

DeleteFileTask:

The tasks deletes one or several files. There are no additional options. At the moment, no wildcards are allowed.

DeleteRegKeyTask:

The task deletes a value of a reg key in the Windows registry. Several hives like HKLM or HKCU can be defined. Note that write permission to the registry must be granted to execute such a task.

WriteLogTask:

Writes a defined text with the time stamp of the execution time into the defined logfile. The logfile header is optional and can be passed as argument (see demo files).

StartProgramTask:

Starts one or several programs with optional arguments. It is possible to define whether the subtasks are executed synchronous or asynchronous. The later can cause freezing of the task runner if an executed application is not terminated (process is still running).

ControlServiceTask:

Starts, restarts, pauses, resumes or stops a Windows Service by its name. It is possible to define a remote machine name. Furthermore, a specific timeout period can be defined.

KillProcessTask:

Terminates one or more processes by its name. It is possible to define a remote machine name.

MetaTask:

A MetaTask loads the configuration files (XML) of other TaskRunner configurations and executes them

Mixed Tasks

If the attribute type in the <task> tag is set to the value MixedTask, any of the available Tasks can be described in one configuration file. Otherwise, only one task type (as Sub-Tasks) is used in one configuration file.

About

Task Runner is a simple Windows command line tool (.NET/C#) to execute several tasks controlled by XML config files, such as deleting files, deleting registry entries, write logfile entries or execute programs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages