IMDTouchKnowledge BaseShop main store

Troubleshooting

Why StartProgram fails to open the keyboard on Unified PC runtime

HMI and touchscreens Published 7 min read

Short answer

A StartProgram keyboard launch that fails with CF_R_CANCELLED and a rejected promise is usually the calling script, not Windows: the method runs asynchronously, so declare the calling script async and await the call. Then test a harmless executable such as notepad.exe through the same call before trying keyboard paths, cmd.exe wrappers or permissions.

On this page
  1. What the RTIL trace actually tells you
  2. Correcting the async call on a Unified V21 PC runtime
  3. Testing a harmless executable first
  4. Paths, cmd.exe wrappers and batch files
  5. Keyboard alternatives on a PC runtime
  6. The decision order
  7. Questions asked

When a script on a WinCC Unified PC runtime tries to open the Windows on-screen keyboard through StartProgram and the RTIL trace answers with a general error and a rejected promise, the defect is usually in the script, not in Windows. The documented behavior is the reason: the RT Unified scripting reference states that StartProgram executes an asynchronous operation without blocking further script execution, so a calling function that is not declared async leaves that promise unhandled. Declare the calling script async and await the call first. If the same trace lines survive that correction, test a harmless executable such as notepad.exe through the identical call before blaming keyboard paths, 32-bit redirection or user permissions. This article reads the trace, walks the script correction on a Unified V21 PC runtime, and ends with the decision order for each branch.

What the RTIL trace actually tells you #

On the failing machine, tapping an input field produced this trace session:

SystemFunction 'StartProgram' failed!
ResultCode: 0x80000002
Error: CF_R_CANCELLED
Description: The component reported a general error
InternalMessage='promise rejected'
(File: D:\agent\_work\16\s\source\ScriptDeviceObjectModelPC\HmiDeviceSysFct.cpp)

None of those lines is a diagnosis on its own. ResultCode 0x80000002 arrives with the component's own description — a general error. CF_R_CANCELLED together with the rejected promise says the asynchronous operation ended without completing. The C++ source path is the build artifact of the component that raised the error, not a pointer to defective code. What the trace does establish: the failure sits inside the StartProgram call path and the promise machinery is involved, which is exactly where an omitted async declaration shows up. What it does not establish: whether the executable path was resolved, whether Windows refused access, or whether the script itself is malformed.

Observation What it supports What it does not prove
CF_R_CANCELLED with a rejected promise The asynchronous StartProgram operation failed before completing Which stage failed: the script call, the path or an access right
The same command runs when typed manually The target exists and executes outside the runtime That the runtime can launch it from its own context
Every path variant gives the identical trace The failure happens before the target is reached That one directory is the cause

Branch-point thinking pays off on other StartProgram failures too: Why the PDF button does nothing on a Unified Comfort panel is the panel-side relative of this problem.

Correcting the async call on a Unified V21 PC runtime #

Inputs from the reported case: WinCC Unified V21 running on a panel PC; an input-field script that calls SysFct.StartProgram with the keyboard path C:\Windows\System32\osk.exe; the calling function declared as a plain function; and the trace above.

The rule, as documented: the launch runs as an asynchronous operation and does not block the rest of the script, and the runtime's asynchronous-operations note explains that a promise holds the result of an operation that has not finished yet. A plain function that calls StartProgram fires the operation and returns immediately; nothing awaits the promise, so a rejection reaches the trace as an unhandled rejection instead of as an error the script could report or retry. A script without syntax errors is not evidence of a valid async call — the editor checks syntax, not promise handling.

The correction, written out as an illustrative example. The function name is my own; the exact parameter list belongs to the SysFct.StartProgram page for your TIA Portal version, and the example keeps the one-string call form the reported scripts use:

// Before: plain function, promise never awaited
function OpenKeyboard {
 SysFct.StartProgram("C:\\Windows\\System32\\osk.exe");
}
// After: async function, promise awaited
async function OpenKeyboard {
 await SysFct.StartProgram("C:\\Windows\\System32\\osk.exe");
}

The proof test: start a fresh RTIL trace session, tap the same input field, and read two things — no failure entry in the new session, and the keyboard window visible on the panel PC. In the reported case this correction alone cleared the error. Decision threshold: if the fresh session still ends in those same trace lines, the script definition is no longer the defect; stop editing the script and run the executable test below.

Testing a harmless executable first #

This branch decides what the trace cannot: whether the runtime can launch any external process at all. Call the same SysFct.StartProgram with a harmless target — bare name or the file's full path as installed on the runtime PC. Two outcomes, each with its decision:

  • If notepad.exe fails with the same trace lines, the defect is in the runtime's launch context — the runtime process, its Windows session, how external launches are handled there. Leave the keyboard executable alone: changing its path cannot fix a launch mechanism that fails for everything.
  • If notepad.exe opens, the launch mechanism works and the difference sits with the keyboard target specifically. Only now do path variants, redirection and access rights for that one executable earn investigation.

Paths, cmd.exe wrappers and batch files #

Only after the async correction and the executable test do the directory variants earn attention: C:\Windows\system32\osk.exe, C:\Windows\SysWOW64\osk.exe, and wrappers such as C:\Windows\system32\cmd.exe /c start osk.exe or C:\Windows\sysnative\cmd.exe /c start osk.exe. The background that makes those variants plausible: on 64-bit Windows, System32 holds the 64-bit system binaries and SysWOW64 holds the 32-bit ones; a 32-bit process asking for System32 is silently redirected to SysWOW64; and sysnative is a virtual alias, visible in no directory listing, that a 32-bit process can use to reach the real 64-bit System32. Redirection explains a file-not-found or a wrong-architecture launch. It does not explain a rejected promise, and in the reported case every variant returned the identical trace, which takes the path layer out as the cause there.

A closely related write-up, WinCC V15.1 StartProgram CMD redirection fix for a TP2200 PRO, works through a command-redirection problem behind the same function on a classic panel.

One safety note: if osk.exe was moved between system directories during earlier tests, put it back in its original location before testing further. Do not reorganize protected Windows files as a diagnostic shortcut.

The batch branch needs the same discipline. A batch file that runs correctly when started by hand proves the command line, not the runtime's ability to call it, and Unified scripts cannot launch a batch file directly — see Why WinCC Unified scripts cannot launch a batch file. Test executable targets through StartProgram, not .bat targets.

Keyboard alternatives on a PC runtime #

The Windows touch keyboard alternative, TabTip.exe under C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe, failed through the same call in the reported case, and it carries its own quirk: once closed, it would not reopen until it was terminated in Task Manager — observed behavior on that machine, not a constant across Windows builds. A Siemens keyboard named CCOnScreenKeyboard.exe was reported to sit in a common Siemens binary directory (Siemens\Common\bin); confirm the file exists on the PC before testing it, and prefer it when present because it is described as more integrated with the HMI than the Windows keyboard.

Two checks that need no script at all. Windows has a setting, under the typing and touch-keyboard options in the Settings app, that opens the touch keyboard automatically when you tap a text field — worth ruling in or out before building any launch script. And if a keyboard launch clearly succeeds but no window appears, the window is most likely positioned off-screen; the steps in How to recover a WinCC on-screen keyboard placed off-screen apply there too.

The decision order #

  1. Read a fresh RTIL session and note the exact failure lines. Change nothing yet.
  2. Open the script behind the input-field action. Confirm the function calling SysFct.StartProgram is declared async and awaits the call; correct it and retest.
  3. Keyboard opens and the new session is clean: done.
  4. Same trace lines again: run the executable test through the identical call.
  5. The simple executable fails the same way: the defect is in the runtime's launch context. Investigate the runtime process and its Windows session, not the keyboard.
  6. The simple executable opens: the fault sits with the keyboard target. Compare its path variants and access rights, record the exact command used for each test, and put any moved system file back first.
  7. A batch file runs by hand but not from the script: expected — switch to an executable target.

Questions asked

Why does an input field open the keyboard on a Unified panel but not on the PC runtime?

On Unified panel hardware the on-screen keyboard is part of the panel software, so tapping an input field opens it by itself. A PC runtime runs on Windows, where the keyboard is a Windows component instead, so whether it appears depends on how the PC and its Windows session are set up. That split is why launching a keyboard executable by script only comes up on PC runtime machines.

What does ResultCode 0x80000002 with CF_R_CANCELLED mean?

It does not name a cause by itself. In the trace it is paired with the description that the component reported a general error and with a rejected promise, which together say that the asynchronous StartProgram operation ended without launching the target. Treat the pair as a branch point: correct the async declaration first, then test a simple executable before touching Windows paths or permissions.

Where else are asynchronous script calls used in WinCC Unified?

The scripting documentation lists timers, network file access and other time-intensive operations as the typical places for asynchronous calls. In practice that means a timer call such as HMIRuntime.Timers.SetTimeout, or any system function that hands back a promise. The same pattern applies to each one: declare the surrounding function async and await the call, so a rejection is handled in your script instead of surfacing in the trace.

Should the batch file or the executable be set to run as administrator?

Only as a last branch. In the reported case the user rights were already correct and every keyboard path produced the same trace, which points away from access control. Try an administrator flag only after the async correction and the notepad.exe test both pass and one specific executable still refuses to start. Note also that a Unified script cannot launch a batch file directly, so marking the batch itself as administrator does not change that limit.

Keep reading

  • Troubleshooting

    Why WinCC Runtime Advanced opens windowed under Operate

    When the runtime is full screen started by hand but windowed when Operate launches it, the project and installation are proven good and the fault is in the Operate integration. With oemframe set, Operate owns the window frame: audit the process registration, the area mapping, the panel type and resolution match, and the Integrate Create MyHMI/WinCC version pairing, and keep the shipped WindowsStyle_Off default.

    HMI and touchscreens

  • How-to

    Selecting a WinCC Unified PC Target in TIA Portal

    An IPC can host WinCC Unified as a PC-based HMI. If the SIMATIC HMI application list shows only WinCC RT Advanced, your TIA Portal installation is missing the Unified PC engineering option: add a PC station, add the SIMATIC WinCC Unified PC application, then match the runtime version and license on the target computer. The hardware is not the deciding check.

    HMI and touchscreens

  • Selection guide

    Where WinCC Unified Runtime Can Run and Remote HMI Options

    The Unified runtime executes only on a PC, a Panel IPC, a Unified Comfort Panel or the MD-34 tablet; a browser or Sm@rtServer VNC client displays it and never replaces the host. With no PC in the cabinet, a Unified Comfort Panel is the host and the tablet browser is the client. If a safety function must travel with the operator, no Unified mobile panel exists and the design stays Comfort-based.

    HMI and touchscreens

Fixing a Missing On-Screen Keyboard From Scripted Input Dialogs