Command Library
CMD, PowerShell, and async command-execution nodes for trusted Windows workflows.
Use this library for trusted command execution, diagnostics, setup tools, and launcher workflows.
Python examples use Unreal's reflected API names through the unreal module. The async command action stays C++-only here because delegate-driven async flows are not practical to execute from Unreal Python.
Include The Module
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
"DeviceFrameworkModule"
}
);#include "HardwareInfoLibrary.h"Command Output
Hidden mode works for normal non-admin commands. Elevated commands use Windows UAC and cannot use the same silent output-capture path.
Run Command Prompt Command
Runs a cmd.exe command immediately.
| Pin | Direction | Purpose |
|---|---|---|
Command | Input | Full command text passed to cmd.exe /S /C. |
bRunAsAdmin | Input | Requests elevation through UAC. |
bHidden | Input | Hides the command window when Windows allows it. |
Return Value | Output | True when the process started successfully. |
#include "HardwareInfoLibrary.h"
const bool bStarted =
USystemInfoBPLibrary::ExecuteWindowsCMD(TEXT("echo Hello from CMD"), false, true);import unreal
started = unreal.SystemInfoBPLibrary.execute_windows_cmd(
"echo Hello from CMD",
False,
True,
)Run PowerShell Command
Runs a powershell.exe command immediately.
| Pin | Direction | Purpose |
|---|---|---|
Command | Input | Full PowerShell command text. |
bRunAsAdmin | Input | Requests elevation through UAC. |
bHidden | Input | Hides the PowerShell window when Windows allows it. |
Return Value | Output | True when the process started successfully. |
#include "HardwareInfoLibrary.h"
const bool bStarted =
USystemInfoBPLibrary::ExecutePowerShell(TEXT("Get-Date"), false, true);import unreal
started = unreal.SystemInfoBPLibrary.execute_power_shell(
"Get-Date",
False,
True,
)Run Command Async
Runs CMD or PowerShell asynchronously without blocking the game thread.
| Pin | Direction | Purpose |
|---|---|---|
WorldContextObject | Input | Async action registration context. |
Command | Input | Command text executed by the selected shell. |
Options | Input | Shell, elevation, hidden mode, output capture, timeout, and working-directory settings. |
Then | Output | Continues immediately after the async action is created. |
On Success | Output | Fires when the command starts and completes successfully. |
On Fail | Output | Fires when the command fails to start, times out, or returns a failure result. |
Result | Output | FWNTCommandResult returned with the success or fail pin. |
FWNTCommandOptions fields:
ShellbRunAsAdminbHiddenbCaptureOutputTimeoutSecondsWorkingDirectory
FWNTCommandResult fields:
bStartedbCompletedbTimedOutExitCodeStdOutStdErr
#include "HardwareInfoLibrary.h"
UFUNCTION()
void HandleCommandSuccess(FWNTCommandResult Result);
UFUNCTION()
void HandleCommandFail(FWNTCommandResult Result);
FWNTCommandOptions Options;
Options.Shell = EWNTCommandShell::PowerShell;
Options.bHidden = true;
Options.bCaptureOutput = true;
Options.TimeoutSeconds = 5.0f;
UAsyncRunCommandAction* Action =
UAsyncRunCommandAction::RunCommandAsync(this, TEXT("Get-Location"), Options);
Action->OnSuccess.AddDynamic(this, &UMyObject::HandleCommandSuccess);
Action->OnFail.AddDynamic(this, &UMyObject::HandleCommandFail);Last updated on