# Interacting with UE4 Editor by commandline - best practice

**URL:** <https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852>\
**Category:** Editor Scripting\
**Tags:** Python, command-line-argumen, command-line, unreal-engine, editor, question\
**Created:** [November 18, 2018, 4:59am UTC](https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852 "2018-11-18T04:59:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mstummer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mstummer](https://forums.unrealengine.com/u/mstummer)\
**Post date:** [November 18, 2018, 4:59am UTC](https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852/1 "2018-11-18T04:59:10Z")

</div>

Hi there!

We would like to integrate UE4 more into our pipeline. We’re particularly interested in automating UE4 related processes via commandline and python scripts. I’ve had a look at the existing documentation:

- [Command-Line Arguments | Unreal Engine Documentation](https://docs.unrealengine.com/en-us/Programming/Basics/CommandLineArguments)
- [Scripting the Editor using Python | Unreal Engine Documentation](https://docs.unrealengine.com/en-US/Editor/Scripting-and-Automating-the-Editor/Scripting-the-Editor-using-Python)

I’ve got a few questions there:

- What’s the difference between **UE4Editor.exe** and **UE4Editor-Cmd.exe**? They both seem to behave the same, and both bring up the GUI. Any preference on which one to use when using UE4 ‘headless’ via the command line?
- How to get logging output from UE4 when using it via the commandline? By default it seems to by totally silent and doesn’t output to stdout or stderr. In order to interact with it properly vie the commandline, we’d need to be able to capture output logging.

Ideally we’d be calling it from within other (non-UE4) Python processes like this:

```
result = subprocess.call('UE4Editor-Cmd.exe -run=pythonscript -script="c:\my_script.py"', stdout=subprocess.PIPE, stderr=subprocess.PIPE )

```

Any advice on best practice there?  
Any help much appreciated!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9c8b25f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9c8b25f](https://forums.unrealengine.com/u/anonymous_user_b9c8b25f)\
**Post date:** [May 29, 2020, 9:16pm UTC](https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852/2 "2020-05-29T21:16:01Z")

</div>

This is pretty old but since there were no answers and I ran into the same problem, I’ll share what I learned.

1. I know that UE4Editor.exe is the full editor and UE4Editor-Cmd.exe “commandlet mode” and intended to run UCommandlets I wasn’t able to get it to successfully run a commandlet though. I’m not sure if it was my game code or not. I decided to run UE4Editor.exe with -nullrhi to run it headless.
2. I was able to get standard output by passing -stdout to UE4Editor.exe. I don’t know why this isn’t documented on [Command-Line Arguments in Unreal Engine | Unreal Engine 5.1 Documentation](https://docs.unrealengine.com/en-us/Programming/Basics/CommandLineArguments) . I only figured it out after I found this page for a python CLI wrapper [https://adamrehn.com/docs/ue4cli/descriptor-commands/run](https://adamrehn.com/docs/ue4cli/descriptor-commands/run) that mentioned a -stdout flag.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_42ac75ca](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_42ac75ca](https://forums.unrealengine.com/u/anonymous_user_42ac75ca)\
**Post date:** [September 29, 2020, 9:12pm UTC](https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852/3 "2020-09-29T21:12:39Z")

</div>

I am also having issues running UEditor -Cmd.exe in because of Oculus failing to initialize in Commandlet mode.  
Do you have exact syntax for running UE4Editor.exe in headless mode, and executing a Python script?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9c8b25f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9c8b25f](https://forums.unrealengine.com/u/anonymous_user_b9c8b25f)\
**Post date:** [September 29, 2020, 9:19pm UTC](https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852/4 "2020-09-29T21:19:31Z")

</div>

I don’t know what you mean by executing a Python script, but the syntax I used was: UE4Editor.exe MyProjectName -nullrhi -stdout -ExecCmds=“My Exec Command;”

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_42ac75ca](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_42ac75ca](https://forums.unrealengine.com/u/anonymous_user_42ac75ca)\
**Post date:** [September 29, 2020, 9:56pm UTC](https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852/5 "2020-09-29T21:56:15Z")

</div>

I was attempting to use this syntax to run a Python script in Commandlet mode:  
UE4Editor-Cmd.exe “C:\projects\MyProject.uproject” -run=pythonscript -script=“c:\my\_script.py”

Fails because Oculus is unable to initialize in Commandlet mode:  
LogOnline: Warning: Oculus: Failed to initialize the Oculus Platform SDK! Failure code: -5  
LogOnline: Warning: Oculus: Oculus API failed to initialize!

Was looking for another was to run the UE4Editor from command line, and execute a Python script?

---

<div class="post-metadata">

**Author:** ![jerryn\_01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jerryn\_01](https://forums.unrealengine.com/u/jerryn_01)\
**Post date:** [March 14, 2023, 5:06pm UTC](https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852/6 "2023-03-14T17:06:55Z")

</div>

Has there been update on this. I created a script but it works in the editor just find but when I try to run it headless it tends to crash.

---

<div class="post-metadata">

**Author:** ![ReflectorRick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ReflectorRick](https://forums.unrealengine.com/u/ReflectorRick)\
**Post date:** [August 4, 2023, 4:12pm UTC](https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852/7 "2023-08-04T16:12:49Z")

</div>

To answer your first question:  
UE4Editor.exe is the editor itself. UE4Editor-Cmd.exe is the command-line for the editor. I’m actually really surprised to hear that UE4Editor-Cmd.exe is opening up the GUI for you. I’ve had it open “live coding” before, but that’s about it.

1. I’m not sure about how to do this in Python, but here’s a way of doing it in C#, maybe you can figure it out how to convert that to Python.

```auto
Process myProcess = new Process();
Process myProcess = new Process();
myProcess .StartInfo.FileName = UE4EditorCmd; //Relative path to UE4Editor.exe
myProcess .StartInfo.Arguments = "myProject.uproject -run=pythonscript"
myProcess .ErrorDataReceived += MyErrorFunc;
myProcess .OutputDataReceived += MyOutputFunc;

myProcess .Start();

myProcess.BeginErrorReadLine();
myProcess.BeginOutputReadLine();
try
{
	if (myProcess.WaitForExit(maxTime))
	{
      //test for different results. A result of 1, 2 or 3 doesn't mean it failed.
     //A result with a negative number means it crashed.

}

        internal static void MyErrorFunc(object _sender, DataReceivedEventArgs _event)
        {
            Console.WriteLine(_event.Data);
        }

//Same idea for MyOutputFunc
```

---

<div class="post-metadata">

**Author:** ![Tireless](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tireless](https://forums.unrealengine.com/u/Tireless)\
**Post date:** [October 1, 2024, 8:48am UTC](https://forums.unrealengine.com/t/interacting-with-ue4-editor-by-commandline-best-practice/437852/8 "2024-10-01T08:48:07Z")

</div>

I was searching for the same info and found this after some digging. Posting for clarity. There is an addon called “PythonScriptPlugin” which has a remote\_execution function you can use. After installing the plugin you can check out this file for info on the commands:  
Engine\Plugins\Experimental\PythonScriptPlugin\Content\Python\remote\_execution.py
