Adding Commands

How to add a command to an automation project for AutomationTool.

Prerequisite Topics

This page assumes you have prior knowledge of the following topics. Please read them before proceeding.

On this page

In the following example, we have a sample command that prints out a Fibonacci sequence of numbers before exiting successfully. Follow this example to add a new command (or script) to your automation project:


Required Step: Before continuing, make sure that there is an empty *.cs source file in the scope of your automation project.

  1. First, make sure to name your source file, and in our example, we named our file SimpleScript.cs.

  2. Now, copy the following sample code into your script:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using AutomationTool;
    namespace SampleScript.Automation
        // Use [Help()] attributes to document your command and its arguments.
        [Help("Sample script printing a Fibonacci sequence of values.")]
        [Help("Usage: SampleScript -Terms=<N>")]
        [Help("Terms=<N>", "N (int) represents how many terms to compute, and it must be greater than or equal to 1.")]
        // BuildCommand is the base class for all commands.
        public class SampleCommand : BuildCommand
            public override void ExecuteBuild()
                // The ParseParamInt() method retrieves a command line argument for this example. ParseParam() retrieves a bool, and ParseParamValue retrieves a string.
                int NumTerms = ParseParamInt("Terms");
                if (NumTerms < 1)
                    throw new AutomationException("Invalid number of terms specified. Enter -help for syntax.");
                    LogInformation("Fibonnacci sequence:");
                    int TermA = 1;
                    int TermB = 1;
                    for (int TermIdx = 0; TermIdx < NumTerms; TermIdx++)
                        LogInformation("  {0}", TermA);
                        int NextTerm = TermA + TermB;
                        TermA = TermB;
                        TermB = NextTerm;
  3. Finally, open a Command Prompt, navigate to Engine\Build\BatchFiles, and enter RunUAT.bat SampleCommand -terms=4.

End Result

You should see the following output:


Select Skin

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback