Run a post-exit command
Overview
The post-exit command lets a channel admin set up one command that ADT Hub runs on a tester's computer right after a game launched from that channel closes. Use it to collect the files a play session leaves behind, such as shader recording files (pipeline state object, or PSO, files), logs or crash files, without asking every tester to gather them by hand.
Key facts:
- Who can set it up: channel admins. A channel admin is a person with the studio Admin role, or the person who created the channel. Other users do not see the setting.
- Where: in ADT Hub, on the Settings tab of the channel settings dialog. The default channel has no post-exit command.
- Where it runs: ADT Hub on Windows only. Admins can set up the command and view its history from ADT Hub on any system.
- What testers see: Hub always shows the command and its live progress in its own window. Testers can cancel it, and it never blocks the game or the next launch.
- What ADT stores: the command text, its settings and a history of changes. ADT never stores your files, tools or passwords. Your studio owns, installs and looks after the tools and credentials the command uses on testers' computers.
The command runs on every tester's computer that plays a build from the channel. Never put passwords, keys or tokens in the command or in named values. Anyone who can open the channel settings or the progress window can read them.
Before you start
Check these on the testers' computers before you turn on the command:
- Tools and credentials. Install every tool the command calls (for example the AWS CLI) and set up its credentials, such as an AWS credentials file or profile. Restart ADT Hub after changing user or system environment variables, because Hub passes the environment it started with.
- Studio IT rules. Make sure the studio's IT rules allow the command runner you pick. For PowerShell, scripts must be allowed to run. Hub runs Windows PowerShell 5.1 and does not bypass the execution policy, so script files your command calls follow the computer's policy.
- Application control and EDR. Hub writes each run's script to
%APPDATA%\<Hub product name>\post-exit\, where<Hub product name>is the name of the ADT Hub app installed on the tester's computer, for example%APPDATA%\ADT Hub\post-exit\. The pre-play warning described below shows the exact path. On computers where application control (AppLocker or Windows Defender Application Control (WDAC) script rules) or an endpoint detection and response (EDR) product blocks scripts outside%WINDIR%and%PROGRAMFILES%, ask IT for a one-time path rule and EDR exclusion for that folder. Keep the rule scoped to that folder only: Hub creates a fresh script there for each run and deletes it when the run ends, so nothing else needs to be excluded. When a tester presses Play on a computer that still blocks it, Hub shows Post-exit command can't run on this PC with the folder path and the options Play anyway and Cancel. The game is never blocked. - Normal user rights. Hub starts the command with the tester's normal user rights, in the game's install folder. Commands must not need administrator rights. If ADT Hub itself is running as administrator, Hub does not run the command and tells the tester to open ADT Hub normally.
- The game's entry point. Hub runs the command when the program it launched exits. Point the build's entry point at the game executable, not at a launcher that starts the game and exits early.
Set up the post-exit command
- In ADT Hub, open the channel, then open the channel settings dialog and select the Settings tab.
- In the Post-exit command section, turn the option on.
- Under How the command runs, keep Windows command prompt or select PowerShell.
- In Command, write the command. Use the values in Values you can use in the runner's own style.
- Click Save. ADT records the change in the channel's history. Click View history to see who changed what and when.
If another admin saved the command after you opened it, Hub shows a message with a Reload button. Copy your changes, reload, and apply them again.
Values you can use
ADT values
ADT gives every run these values, filled in for that tester and that game close. They are environment variables, so write them in the runner's normal style.
| Name | Meaning | Format | Example | Command prompt / PowerShell |
|---|---|---|---|---|
ADT_GAME_DIR | The folder where this build is installed on the tester's computer | Full folder path, no trailing backslash. May contain spaces. | D:\ADT Games\MyGame\Main-Playtest | "%ADT_GAME_DIR%" / "$env:ADT_GAME_DIR" |
ADT_GAME_VERSION | The version of the build that was played, as ADT shows it | Text | 1.4.2-CL12345 | "%ADT_GAME_VERSION%" / "$env:ADT_GAME_VERSION" |
ADT_BUILD_TRACK | The name of the build track the game was launched from | Text. May contain spaces. | Main Playtest | "%ADT_BUILD_TRACK%" / "$env:ADT_BUILD_TRACK" |
ADT_GAME_EXIT_STATUS | How the game closed | normal (exit code 0) or crashed (any other way) | crashed | "%ADT_GAME_EXIT_STATUS%" / "$env:ADT_GAME_EXIT_STATUS" |
ADT_GAME_EXIT_CODE | The raw exit code the game returned | Whole number, may be negative | -1073741819 | "%ADT_GAME_EXIT_CODE%" / "$env:ADT_GAME_EXIT_CODE" |
The command does not receive the values Hub passes to the game at launch, such as the tester's display name, email address or role. Names starting with ADT_ are reserved for ADT.
Named values
Channel admins can also define their own named values, for example a storage location shared by several commands. Each name becomes an environment variable for the command.
To add one, go to the Post-exit command section on the channel's Settings tab, click Add value under Your named values, enter the name and value, and click Save.
- Up to 50 named values per channel.
- A name starts with a letter or underscore, and has only letters, digits and underscores, up to 64 characters. Names are not case-sensitive and must be unique.
- A name cannot start with
ADT_orELECTRON_, and cannot beNODE_OPTIONSor a Windows system value such asPATH,TEMP,TIMEorDATE. - A value has up to 1,024 characters and no line breaks.
Named values are not secret. Do not store passwords or keys in them.
If you remove a named value that the command still uses, Hub warns you after you save.
Values from the tester's computer
The command also sees the tester's normal Windows environment, such as %LOCALAPPDATA% / $env:LOCALAPPDATA and %COMPUTERNAME% / $env:COMPUTERNAME. The progress window never lists these values.
Command prompt and PowerShell styles
Use the style of the runner you picked. The other style is not converted and stays as plain text.
| Command prompt | PowerShell | |
|---|---|---|
| A value | %ADT_GAME_DIR% | $env:ADT_GAME_DIR |
| A value in a path | "%ADT_GAME_DIR%\MyGame\Saved" | "$env:ADT_GAME_DIR\MyGame\Saved" |
If the output shows the reference itself, for example The user-provided path $env:ADT_GAME_DIR\... does not exist, the command uses the wrong style for the runner. Change the runner or rewrite the references. When you switch the runner on a command that is not empty, Hub reminds you to check the style.
Quote every value
Put every value in double quotes, even values that usually have no spaces. Install folders and track names can contain spaces, and quoting stops a value from being read as several arguments.
:: Command prompt
dir "%ADT_GAME_DIR%\MyGame\Saved\Logs"
# PowerShell
Get-ChildItem "$env:ADT_GAME_DIR\MyGame\Saved\Logs"
Hub does not run the command when the build version or the track name contains characters that cannot be used safely in a command. The tester sees This command didn't run. The build version or track name contains characters that can't be used safely in a command. Ask a channel admin to rename it. Letters in any language, digits, spaces and . _ - + / : @ # , [ ] ' are allowed. To fix it, rename the build track in ADT, or upload the build again with a version name that uses only those characters.
Example: upload shader recording files
This example collects the Unreal Engine shader recording files (*.rec.upipelinecache) a play session writes, and uploads them to your own Amazon S3 bucket. Replace my-studio-bucket, MyGame and my-profile with your own values.
-
Turn on recording. Add
-logPSOto the track's launch arguments, so the game writes recording files during play. See Launch arguments. -
Prepare the testers' computers. Install the AWS CLI and set up a profile with permission to write to the bucket, for example in
%USERPROFILE%\.aws\credentials. -
Write the command. Select one of the following.
Windows command prompt:
aws s3 cp "%ADT_GAME_DIR%\MyGame\Saved\CollectedPSOs" "s3://my-studio-bucket/pso/%ADT_GAME_VERSION%/%COMPUTERNAME%/" --recursive --exclude "*" --include "*.rec.upipelinecache" --profile my-profilePowerShell:
aws s3 cp "$env:ADT_GAME_DIR\MyGame\Saved\CollectedPSOs" "s3://my-studio-bucket/pso/$env:ADT_GAME_VERSION/$env:COMPUTERNAME/" --recursive --exclude "*" --include "*.rec.upipelinecache" --profile my-profile
exit $LASTEXITCODE -
Check the result. Play the build in ADT Hub and close the game. The progress window shows the upload output and Succeeded. Then list the bucket, for example
aws s3 ls s3://my-studio-bucket/pso/ --recursive --profile my-profile.
If your game writes files to the user's app data folder instead of the install folder, point the command there:
:: Command prompt
aws s3 cp "%LOCALAPPDATA%\MyGame\Saved\CollectedPSOs" "s3://my-studio-bucket/pso/%ADT_GAME_VERSION%/%COMPUTERNAME%/" --recursive --exclude "*" --include "*.rec.upipelinecache" --profile my-profile
# PowerShell
aws s3 cp "$env:LOCALAPPDATA\MyGame\Saved\CollectedPSOs" "s3://my-studio-bucket/pso/$env:ADT_GAME_VERSION/$env:COMPUTERNAME/" --recursive --exclude "*" --include "*.rec.upipelinecache" --profile my-profile
exit $LASTEXITCODE
Use aws s3 sync instead of aws s3 cp --recursive to send only files that are not already in storage. If one run fails, the next successful run catches up on the missed files.
Write reliable commands
Success and failure
A run is Succeeded only when the command ends with exit code 0. Any other exit code is Failed. Make your scripts end with a non-zero exit code when they fail.
- In PowerShell, end with
exit $LASTEXITCODEafter a native tool such asaws, so the tool's exit code becomes the result. - In command prompt, the exit code of the last command is the result. Use
exit /b 1to fail on purpose.
How each runner runs the command
- Command prompt runs the command as a batch file. Write
%%iinFORloops and%%for a literal percent sign. One line is limited to 8,191 characters after values are filled in. Labels starting withadt_pec_are reserved. - PowerShell runs Windows PowerShell 5.1. Errors and warnings appear as plain text in the progress window.
- Output is read as UTF-8. Tools that ignore the console code page may still show garbled text.
Never wait for input
The command gets no keyboard input. Prompts such as pause and set /p continue at once. Tools that read the console directly keep waiting until the 10-minute limit and end as Timed out. Write commands that never ask the tester to type or press a key.
Programs the command starts
Hub runs the command and everything it starts as one group. When the command finishes, is cancelled, times out or Hub quits, Hub closes every program the command started and left running, for example a browser opened with start https://... or Notepad opened on a log. Use start /wait, or call tools directly, so the command waits for them.
A tool that tries to start a process outside this group fails inside a post-exit command. Programs started through another service, such as a scheduled task or a file opened in an app that is already running, are outside the group and keep running.
Keep output free of secrets
Testers can copy the output and send it to you. Start batch scripts with @echo off, and never print passwords, keys or tokens.
Write safely re-runnable commands
A run can fail or be cancelled, for example when the network drops. Files that were not sent stay where the game left them, and ADT does not move or delete them. Write commands that send only files not already in storage, so the next successful run catches up, whether that is a Run again or the next game close.
Share the network with trace uploads
ADT Hub's performance trace upload uses the same network as the command. A large trace upload can slow a large file upload toward the 10-minute limit.
What testers see
When a game launched from the channel closes, Hub opens the Post-exit command window. It shows the saved command, who last changed it, a Values used list (ADT values and named values only), live output and Cancel.
| Result | When | What the window shows |
|---|---|---|
| Succeeded | Exit code 0 | "Post-exit command succeeded." The window closes after 10 seconds. |
| Failed | Any other exit code | "Post-exit command failed (exit code N). Copy the output and send it to your channel admin." |
| Failed (couldn't start) | Hub could not start the command, for example on a computer whose security policy blocks it, or when ADT Hub runs as administrator | A message that explains why, to send to the channel admin |
| Timed out | Still running 10 minutes after it started | "Post-exit command stopped after 10 minutes. Copy the output and send it to your channel admin." |
| Cancelled | The tester cancelled | "Post-exit command cancelled." |
Every finished window has Copy output. When the result is Failed, Timed out or Cancelled, the window also has Run again. Other behavior testers may see:
- Several game closes in a row. Commands run one at a time. A later command waits for the earlier one to finish.
- Play while a command runs. Hub asks the tester to Wait for the command or Cancel and play. If the tester waits, the build launches when the command finishes, and the launch can still be cancelled from the progress window.
- Quit while a command runs. Hub asks for confirmation, because quitting cancels the command. A Hub update waits until the command finishes.
- A crash or force-close. The command still runs, with
ADT_GAME_EXIT_STATUSset tocrashed. Your command decides what to do. - Run again. After fixing the cause, for example after signing in to the upload tool, the tester clicks Run again to run the command once more without playing the game again. The new run uses the same ADT values from that game close and the latest saved command, and it is recorded as its own run. Hub never retries on its own. Run again is not offered for Failed (couldn't start) or Succeeded, and Hub refuses it while a game launched from Hub or another post-exit command is running.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Output shows %ADT_GAME_DIR% or $env:ADT_GAME_DIR as text | The command uses the other runner's style | Rewrite the references in the runner's style, or switch the runner |
'aws' is not recognized or The term 'aws' is not recognized | The tool is not installed, or Hub started before the tool was added to PATH | Install the tool, then restart ADT Hub |
Failed with a sign-in or credentials error, such as Unable to locate credentials or an expired SSO token | The tester is not signed in to the upload tool, or the sign-in expired | Sign in to the tool, for example with aws sso login, then click Run again in the window |
| Failed (couldn't start) with a security policy message | Application control or EDR blocks scripts in the post-exit folder | Ask IT for the path rule and EDR exclusion in Before you start |
| The command didn't run because ADT Hub is running as administrator | Hub was started with Run as administrator | Close ADT Hub and open it normally |
| The command didn't run because of unsafe characters | The build version or track name has characters outside the allowed set | Rename the track, or upload the build with a different version name |
| Timed out | The command waited for input, or the upload took more than 10 minutes | Remove prompts; upload fewer or smaller files, or use aws s3 sync |
| The command runs as soon as the game starts | The entry point is a launcher that exits early | Point the entry point at the game executable |