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.

Include The Module

Command Output

Hidden mode works for normal non-admin commands. Elevated commands use Windows UAC and cannot use the same silent output-capture path.

Source/MyProject/MyClass.cpp
#include "HardwareInfoLibrary.h"
Source/MyProject/MyProject.Build.cs
PublicDependencyModuleNames.AddRange(
	new string[]
	{
		"Core",
		"CoreUObject",
		"Engine",
		"DeviceFrameworkModule"
	}
);

Run Command Prompt Command

Runs a cmd.exe command immediately.

This synchronous node is formally deprecated in favor of the unified async flow provided by Execute CLI Commands.

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"

  void AMySystemHelper::RunPromptCommand()
{
    const bool bStarted = USystemInfoBPLibrary::ExecuteWindowsCMD(TEXT("echo Hello from CMD"), false, true);
    if (bStarted)
    {
        UE_LOG(LogTemp, Log, TEXT("Command prompt started."));
    }
}

Run PowerShell Command

Runs a powershell.exe command immediately.

This synchronous node is formally deprecated in favor of the unified async flow provided by Execute CLI Commands.

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"

  void AMySystemHelper::RunPowerShellCommand()
{
    const bool bStarted = USystemInfoBPLibrary::ExecutePowerShell(TEXT("Get-Date"), false, true);
    if (bStarted)
    {
        UE_LOG(LogTemp, Log, TEXT("PowerShell command started."));
    }
}

Execute CLI Commands

Runs CMD or PowerShell asynchronously without blocking the game thread. Features thread-safe isolated data pipes to prevent memory contamination during concurrent execution.

Timeout Warning

If the command times out, a timeout warning is prepended to the Error field, safely preserving any diagnostic output the child process wrote before termination.

Run As Admin

Standard output capture is physically impossible when "Run As Admin" is checked due to Windows UAC process isolation.

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 strictly when the OS ExitCode is 0.
On FailOutputFires when the command crashes, times out, fails to start, or returns a non-zero exit code.
ResultOutputFWNTCommandResult returned with the success or fail pin.
C++ Example
#include "HardwareInfoLibrary.h"

// Define these functions in your header file
// UFUNCTION() void HandleCommandSuccess(FWNTCommandResult Result);
// UFUNCTION() void HandleCommandFail(FWNTCommandResult Result);

void AMySystemHelper::ExecuteAsyncCommand()
{
    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, &AMySystemHelper::HandleCommandSuccess);
    Action->OnFail.AddDynamic(this, &AMySystemHelper::HandleCommandFail);
}

FWNTCommandOptions Fields

FieldDescription
ShellDefines which shell to execute (CMD or PowerShell).
bRunAsAdminWhether to execute the command with elevated privileges via UAC.
bHiddenHides the console window during execution.
bCaptureOutputCaptures standard output and standard error for the result.
TimeoutSecondsMaximum time in seconds before the process is forcefully killed.
WorkingDirectoryThe directory path to run the command in.

FWNTCommandResult Fields

FieldDescription
ExitCodeThe exit code returned by the process upon completion.
TextOutputThe standard output text printed by the command.
ErrorThe standard error text, or warnings if the command timed out.

Last updated on

On this page