Windows Native Toolkit

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

Source/MyProject/MyProject.Build.cs
PublicDependencyModuleNames.AddRange(
	new string[]
	{
		"Core",
		"CoreUObject",
		"Engine",
		"DeviceFrameworkModule"
	}
);
Source/MyProject/MyClass.cpp
#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.

PinDirectionPurpose
CommandInputFull command text passed to cmd.exe /S /C.
bRunAsAdminInputRequests elevation through UAC.
bHiddenInputHides the command window when Windows allows it.
Return ValueOutputTrue when the process started successfully.
C++ Example
#include "HardwareInfoLibrary.h"

const bool bStarted =
    USystemInfoBPLibrary::ExecuteWindowsCMD(TEXT("echo Hello from CMD"), false, true);
Python Example
import unreal

started = unreal.SystemInfoBPLibrary.execute_windows_cmd(
    "echo Hello from CMD",
    False,
    True,
)

Run PowerShell Command

Runs a powershell.exe command immediately.

PinDirectionPurpose
CommandInputFull PowerShell command text.
bRunAsAdminInputRequests elevation through UAC.
bHiddenInputHides the PowerShell window when Windows allows it.
Return ValueOutputTrue when the process started successfully.
C++ Example
#include "HardwareInfoLibrary.h"

const bool bStarted =
    USystemInfoBPLibrary::ExecutePowerShell(TEXT("Get-Date"), false, true);
Python Example
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.

PinDirectionPurpose
WorldContextObjectInputAsync action registration context.
CommandInputCommand text executed by the selected shell.
OptionsInputShell, elevation, hidden mode, output capture, timeout, and working-directory settings.
ThenOutputContinues immediately after the async action is created.
On SuccessOutputFires when the command starts and completes successfully.
On FailOutputFires when the command fails to start, times out, or returns a failure result.
ResultOutputFWNTCommandResult returned with the success or fail pin.

FWNTCommandOptions fields:

  • Shell
  • bRunAsAdmin
  • bHidden
  • bCaptureOutput
  • TimeoutSeconds
  • WorkingDirectory

FWNTCommandResult fields:

  • bStarted
  • bCompleted
  • bTimedOut
  • ExitCode
  • StdOut
  • StdErr
C++ Example
#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

On this page