David Williams Technical


Endpoint Management & Deployment – MDM Management – Scripting – Cyber Security Engineering – Application Configuration & Deployment

How to Deploy Unreal Engine

This document outlines the process of downloading and deploying Unreal Engine. This process outlines the steps you need to create the installer and the script required to deploy the software. Please be aware that the script requires editing depending on the version you extract.

Note: I have used this process to deploy versions 4 and 5.


The deployment can be broken down into a few parts:

  1. Download the engine build needed from the launcher
  2. Zip up the build files
  3. Create the version config file
  4. Create a desktop shortcut
  5. Update the deployment batch script with current version numbers
  6. Test Deployment manually on a clean machine

Firstly, you may need to change some parts for your own policies, such as firewall rule installations, and the user group granted write permissions. The main script is the Deploy_UnrealEngine.cmd which uses the other files in common and UE_Version_4.20. You will require a copy of 7za, a command line version of 7zip used to extract the engine on the target machine.

So this is the easiest bit – Just run the normal launcher from Epic and install the second to latest version of Unreal Engine. For the sake of this tutorial I’ll be assuming the version we’re installing is 4.20.3.

This is an important part of the process – Pick the same location to install now as you want on the deployment as we’ll make a shortcut to it later. I use the C:\Epic\ directory as it allows separate permissions than the Program Files directory. This will take a little while to install. You should also note that when completing this process you will need to test the completed script and deployment on a separate PC or virtual machine.

The next step is to zip up the engine files, as copying the tens of thousands (literally) of small files will take forever over the network. I found that using 7Zip to split to 700MB is a nice balance between number of files, and time lost when inevitably the copy fails and has to restart. 

Zip up the UE4.20 directory in C:\Epic\. The easiest way to do this and to keep the file structure correct inside the zip is to right click the UEX.XX folder and “add to archive”.

The following settings work well:

  • Container: 7z – It’s the fastest to extract, and smallest file size
  • Speed: fastest –  A trade off between file size, compression and decompression speed.
  • File Split: 700M – CD

Copy these to your deployment server – so if a computer’s build goes wrong then any admin can re-download it and fix it easily.


The Launcher gets details of what it has installed from the LauncherInstalled.dat file in C:\ProgramData\Epic\UnrealEngineLauncher. This is a json file which contains an entry for each installed engine, game, plugin etc.

What we want to do is extract the installation data for the engine version we want, and then rebuild this file on each machine, depending on what is actually installed to it.

For now, this boils down to just extracting the middle section for the engine we’re using and saving it out alongside our zip of the engine build, titled UE_4.20.dat. Make sure to keep the “,” after the final curly brace and the indentations.


{

“InstallLocation”: “C:\\Epic\\UE4\\UE_4.20”,

“AppName”: “Substance_4.20”,

“AppID”: 0,

“AppVersion”: “4.20.0-4234380+++depot+UE4-UserContent-Windows”

},

{

“InstallLocation”: “C:\\Epic\\UE4\\UE_4.20”,

“AppName”: “UE_4.20”,

“AppID”: 20040003,

“AppVersion”: “4.20.3-4369336+++UE4+Release-4.20-Windows”

},


What happens in the installation script is it wraps a header and footer around each of the engine, plugin and game .dats we’re creating and rebuilds it on any new deployments. 

Note: that you must use the exact information from the dat created by the launcher when you downloaded and zipped your version. Different files may differ in major and/or minor version numbers!

The deployment script will flag the newly created Launcherinstalled.dat file as read-only to stop the Launcher from overwriting the installation as “it” didn’t create it. This is a hack to ensure it deploys correctly.


Next is to create Shortcut for the Desktop

One of the drawbacks for using this method is you’re not able to run the engine from the launcher anymore. One of the ways we simplify this is to add a shortcut to the desktop and start menu for launching the engine. It is located in:

C:/Epic/UE_**/Win64/binaries/UnrealEditor

Create a shortcut on the desktop and copy this to the deployment folder. Make sure this matches the name in the script.


In all likelihood you’ll be using a newer build than the one described in this guide, so change the major and minor version in the Deploy_UnrealEngine_4.20.3.cmd batch script to match the engine build you’re deploying, and rename it. The script references the version from the top of the script, so it’s easy to update as needed. Also included here are options to change the network share directory, install location (make sure your shortcut matches!) and shortcut location.


So we should be ready to perform a test deployment!! We have our build files and now we can do a test deployment. The script should work fine if run locally when elevated (check your share permissions if you hit issues). It will copy the files to a temporary location, extract them, install the engine specific prerequisites for x86 and x64, add firewall rules, copy the shortcuts and finally delete the temporary zip files. Add a pause to the end of the script to check the install.


This is an example of my script I have used….. It is for the most recent version I installed!!


@ECHO ON

:: SILENT INSTALLER FOR UNREAL ENGINE 5

:: Last Edited by Dave Williams 10/05/2022

:: Updated to 5.0.1

:: ==================

:: SET VERSION AND SHARE LOCATION

SET MAJOR=0

SET MINOR=1

SET NETWORK_SHARE=\\Deployment_Share\UnrealEngine\UE5

SET INSTALL_DIR_UE5=C:\Epic\UE5

:: ==================

:: ————————————————————–

:: DO NOT EDIT AFTER THIS POINT UNLESS THE VERSION HAS CHANGED

:: ————————————————————–

:: CORRECT THE DIRECTORY WHEN RUNNING AS ADMIN, AND ALLOWS LOCAL FILE REFERENCING

PUSHD %~dp0

:: PROCESS INITIAL VARS

:: ——————————————————-

SET SOURCE_DIR_UE5=%NETWORK_SHARE%\5.%MAJOR%.%MINOR%

SET SOURCE_COMMON=%NETWORK_SHARE%\common

SET ZIP_INSTALL_FILES=UE_5.%MAJOR%

SET SHORTCUT_FILE_UE5=”Unreal Engine 5.%MAJOR%.%MINOR%.lnk”

SET FIREWALL_RULENAME=”UE_5.%MAJOR%.%MINOR%”

SET FIREWALL_PROGPATH=”%INSTALL_DIR_UE5%\UE_5.%MAJOR%\Engine\Binaries\Win64\UnrealEditor.exe”

SET INST_VERS_FILE=”C:\Epic\versions\UE_5.0.1.dat”

:: REMOVE EXISTING MATCHING VERSIONS

:: ——————————————————-

:: DELETE EXISTING VERSION IF PRESENT – EG REMOVES 4.21.2 TO INSTALL 4.21.3

IF EXIST “%INSTALL_DIR_UE4%\UE_4.%MAJOR%” RMDIR /S /Q “%INSTALL_DIR_UE4%\UE_4.%MAJOR%”

:: REMOVE DESKTOP ICON FOR EXSITING MAJOR VERSION

IF EXIST “C:\Users\Public\Desktop\Unreal Engine 4.%MAJOR%.*.lnk” del “C:\Users\Public\Desktop\Unreal Engine 4.%MAJOR%.*.lnk” /F /Q

:: REMOVE .DAT VERSIONS FILE FOR MARTCHING MAJOR VERSIONS

IF EXIST “C:\Epic\versions\UE_4.%MAJOR%.*.dat” del “C:\Epic\versions\UE_4.%MAJOR%.*.dat” /F /Q

:: MAIN INSTALLER

:: ——————————————————-

IF NOT EXIST “%INSTALL_DIR_UE5%” mkdir “%INSTALL_DIR_UE5%”

:: COPY FILES TO TEMP DIR UNDER INSTALL DIR – RETRY 999 times with 30SEC WAIT

ROBOCOPY “%SOURCE_DIR_UE5%” “%INSTALL_DIR_UE5%\temp_5.%MAJOR%.%MINOR%” “%ZIP_INSTALL_FILES%.7z.*” /J /r:999 /w:30

:: EXTRACT FILES WITH 7ZIP – USING AOS TO SKIP EXISTING

%SOURCE_COMMON%\7za\7za.exe x -aos “%INSTALL_DIR_UE5%\temp_5.%MAJOR%.%MINOR%\%ZIP_INSTALL_FILES%.7z.001″ -o”%INSTALL_DIR_UE5%\”

:: GRANT PERMISSIONS – ALLOWS ENGINE TO BE BUILT

ICACLS “C:\Epic” /Q /grant “Authenticated Users”:M

:: VERIFY LAUNCHER FIREWALL RULES

:: ——————————————————-

NETSH advfirewall firewall show rule name=UE_LAUNCHER_out >nul

IF NOT ERRORLEVEL 1 (

    ECHO Rule UE_LAUNCHER_out Already Exists

) ELSE (

    ECHO Rule UE_LAUNCHER_out not exist. Creating…

    NETSH advfirewall firewall add rule name=UE_LAUNCHER_out dir=out program=”C:\program files (x86)\epic games\launcher\portal\binaries\win64\epicgameslauncher.exe” enable=yes profile=any action=allow description=UE_LAUNCHER_out

)

NETSH advfirewall firewall show rule name=UE_LAUNCHER_in >nul

IF NOT ERRORLEVEL 1 (

    ECHO Rule UE_LAUNCHER_in Already Exists

) ELSE (

    ECHO Rule UE_LAUNCHER_in not exist. Creating…

    NETSH advfirewall firewall add rule name=UE_LAUNCHER_in dir=in program=”C:\program files (x86)\epic games\launcher\portal\binaries\win64\epicgameslauncher.exe” enable=yes profile=any action=allow description=UE_LAUNCHER_in

)

:: INSTALL VERSION FIREWALL RULES

:: ——————————————————-

NETSH advfirewall firewall show rule name=%FIREWALL_RULENAME%_out >nul

IF NOT ERRORLEVEL 1 (

    ECHO Rule %FIREWALL_RULENAME%_out already exist.

) ELSE (

    ECHO Rule %FIREWALL_RULENAME%_out not exist. Creating…

    NETSH advfirewall firewall add rule name=%FIREWALL_RULENAME%_out dir=out program=%FIREWALL_PROGPATH% enable=yes profile=any action=allow description=%FIREWALL_RULENAME%_out

)

NETSH advfirewall firewall show rule name=%FIREWALL_RULENAME%_in >nul

IF NOT ERRORLEVEL 1 (

    ECHO Rule %FIREWALL_RULENAME%_in already exist.

) ELSE (

    ECHO Rule %FIREWALL_RULENAME%_in not exist. Creating…

    NETSH advfirewall firewall add rule name=%FIREWALL_RULENAME%_in dir=in program=%FIREWALL_PROGPATH% enable=yes profile=any action=allow description=%FIREWALL_RULENAME%_in

)

:: INSTALL PREREQUISITES – THE MAIN PART THAT USERS ARE UNABLE TO DO

:: ——————————————————-

%INSTALL_DIR_UE5%\UE_5.%MAJOR%\Engine\Extras\Redist\en-us\UE5PrereqSetup_x64.exe /q

%INSTALL_DIR_UE5%\UE_5.%MAJOR%\Engine\Extras\Redist\en-us\UE5PrereqSetup_x86.exe /q

:: COPY DESKTOP SHORTCUT

:: ——————————————————-

ROBOCOPY “%SOURCE_DIR_UE5%” “C:\Users\Public\Desktop” %SHORTCUT_FILE_UE5%

:: CONSTRUCT LAUNCHER INSTALLEDVERSIONS.DAT – ENSURES BUILDS WORK WITH RIGHT CLICK MENU AND FILE TYPE ASSOCIATIONS

:: ——————————————————-

:: COPY NEW VERSION FILE TO POOL FOLDER

ROBOCOPY “%SOURCE_DIR_UE5%” “C:\Epic\versions” “UE_5.%MAJOR%.%MINOR%.dat”

:: REMOVE EXISTING – WILL REMOVE SUB VERSION EG 4.21.2 WHEN INSTALLING 4.21.3

IF EXIST %INST_VERS_FILE% del %INST_VERS_FILE% /F /Q

:: BUILD THE LAUNCERINSTALLED.DAT FILE INCLUDING ALL UNREAL ENGINE AND UNREAL TOURNAMENT BUILDS – CAN BE EXPANDED TO OTHERS IF NEEDED

TYPE %SOURCE_COMMON%\header.dat >> %INST_VERS_FILE%

IF EXIST C:\Epic\versions\UE*.dat TYPE C:\Epic\UE*.dat >> %INST_VERS_FILE%

TYPE %SOURCE_COMMON%\footer.dat >> %INST_VERS_FILE%

:: MARK AS READ ONLY – STOPS THE LAUNCHER FROM OVERWRITING THE VERSIONS SHOULD IT BE LAUNCHED

attrib +R  %INST_VERS_FILE%

:: ADD FILE TYPE ASSOCIATIONS TO REGISTRY

:: ——————————————————-

REG IMPORT %SOURCE_COMMON%\uProjectAssociation.reg

:: REMOVE ZIPS FROM THE TEMP DIRECTORY

:: ——————————————————-

::IF EXIST “%INSTALL_DIR_UE5%\temp_5.%MAJOR%.%MINOR%” RMDIR /S /Q “%INSTALL_DIR_UE5%\temp_5.%MAJOR%.%MINOR%”

::RETURN TO PREVIOUS WORKING DIRECTORY (AFTER PUSHD)

:: ——————————————————-

POPD

REM PAUSE