Troubleshooting
Why StartProgram runs notepad but shows no window or stdout
Short answer
HMIRuntime.Device.SysFct.StartProgram runs the executable in the runtime host's own Windows context, and the vendor documentation states it cannot start a program with a user interface. A process in Task Manager with no window and no captured stdout is therefore expected. Give the helper absolute paths for input, output and its own log file, and read completion status from that log.
On this page
StartProgram is doing exactly what its documentation says. The method HMIRuntime.Device.SysFct.StartProgram starts an external application as an asynchronous operation on the machine where the Unified runtime runs, and the vendor documentation states it cannot start a program with a user interface. So when you call it with notepad.exe, the process appears in Task Manager on the runtime PC as a background process, no window opens anywhere, and there is no stdout or stderr to look at. That is expected behavior, not a broken script. The fix is not to fight for a window: build the helper to run headless, hand it explicit absolute paths for input, output and its own log file, and read the completion status from that log instead of from a console.
Separate the launch from the session #
A process and a session are different things. A session is the Windows environment attached to a logon or a service; a process can be created successfully inside a noninteractive context and never display anything on the operator's desktop. Task Manager proves process creation. It proves nothing about a window, a console or either output stream.
Notepad is therefore a poor acceptance test for this integration. Use a helper written to run without any operator interaction. If the real requirement is an interactive third-party application visible to the operator, the StartProgram method is the wrong tool by its own documentation, and you should look for the supported integration methods in the Unified documentation you have installed rather than trying to push a background process onto a desktop.
A browser client is an even harder boundary. Browser JavaScript runs under the browser's own security model and is not a Windows shell; the runtime's scripting API on the host is where this method belongs. For the different case where a scripted StartProgram call refuses to open even the on-screen keyboard on a Unified PC runtime, see why StartProgram fails to open the keyboard on Unified PC runtime.
Commission the launch itself with two checks:
- Trigger the call once, then inspect Task Manager on the runtime PC. The executable should appear there.
- Record the process user and session shown for that process. The test passes on process creation and identity, not on a visible window.
Get the call syntax right #
Separate JavaScript string rules from Windows path rules. In a JavaScript string literal a single backslash starts an escape sequence, so a Windows path must use doubled backslashes or the call receives a mangled string. The call pattern looks like this, with the numeric arguments taken in the order shown by the help of your installed runtime version:
HMIRuntime.Device.SysFct.StartProgram("c:\\Windows\\system32\\notepad.exe", "", 1, 0, null);
Read the function signature in the help matching your installed runtime before relying on any argument beyond the executable path and the argument string. In particular, do not read the numeric options as a promise that a window will appear; the documentation is explicit that the method cannot start a program with a user interface. The method reference in the WinCC Unified JavaScript object model documents the asynchronous, non-blocking execution and the device restrictions you need to check.
For a production helper, always give the absolute path to the executable. An absolute path identifies the file independently of any working directory, and it removes dependence on executable search behavior that can differ between your logged-in engineering session and the runtime's execution context.
Working directory and account permissions #
The method exposes no working-directory argument, and the directory containing the executable does not decide where the process reads or writes relative paths. Two failures follow from that, and both are common:
- The helper resolves its input or configuration file relative to its working directory, starts fine, and finds nothing.
- The helper writes its output or log to a relative path, runs to completion, and the results land somewhere nobody looks, or the write fails.
File access follows the account running the process, which is not necessarily the account you used for your successful manual test. A manual run that reads and writes the right files proves nothing about the runtime-launched process.
The decision is simple: make the helper accept explicit input, output, configuration and log locations through its own documented interface, or resolve its resources deliberately in code. Where arguments carry paths, apply the quoting rules of that executable; JavaScript escaping and command-line quoting solve different problems.
Replace the invisible console with owned logging #
Standard output and standard error are process streams, not HMI messages, and StartProgram gives you no parameter to collect them. Putting shell redirection characters into the argument string is not a general fix either: a command shell interprets redirection, and a directly launched executable can receive those characters as ordinary arguments.
So give the helper its own logging. For the first commissioning run, have it write to an absolute log location the runtime account can access, and record launch time, the resolved working directory, the execution identity, each resolved file path, processing milestones, error details and an explicit completion record. That log is what distinguishes a failure to launch from a failure after startup, and it is what you read in place of stdout.
Worked example. Suppose the helper converts a daily production CSV for the HMI and you configure it from the HMI like this: input d:\hmidata\shift_2024_06_03.csv, output d:\hmidata\shift_2024_06_03.json, log d:\hmidata\helper.log. The helper appends to helper.log: 2024-06-03 06:00:02 start, 2024-06-03 06:00:02 working dir d:\hmidata, 2024-06-03 06:00:03 read 1440 rows, 2024-06-03 06:00:03 wrote shift_2024_06_03.json 1440 records, 2024-06-03 06:00:03 done status=0. The last line, an explicit completion record with a status code you defined, is the handshake. When the input file is missing, the same log instead shows the resolved path it tried and done status=2, which tells you the launch worked and the input failed — something Task Manager can never tell you.
Keep the launch controlled. Decide which executable may be started and which arguments are permitted, and never let arbitrary HMI text become part of a command line.
Decide completion with a handshake, not with Task Manager #
A process appearing is not a completion signal and a process disappearing is not proof of success. Launch and data processing are separate events, so define an explicit handshake between the HMI and the helper: a request identifier, a busy state, a success or failure status and who owns the result file. The status tag or result file the HMI reads must be written by the helper itself, from inside the process, so it reflects the actual work.
The bench test for the whole chain, on an isolated machine with test files you control:
- Trigger the launch once from the HMI. The helper starts, logs startup with the resolved paths, processes the test input and writes a completion record with a success status.
- Run a controlled invalid-input case. The log identifies the rejected input and a failure status instead of merely reporting that a process started.
- Check that the HMI displays the status it read from the helper's output, not an assumption based on elapsed time.
If all three pass, the integration is working as the method intends: a headless helper on the runtime host, explicit paths, owned logging and an explicit handshake — with no window and no stdout, by design.
Questions asked
Why does notepad.exe appear in Task Manager but show no window on the runtime PC?
The documentation for the StartProgram method states that it cannot start a program with a user interface. The process is created asynchronously in the runtime host's execution context, so it runs and Task Manager lists it, but no window is attached to any interactive desktop. That is the documented behavior, not a fault in your script.
How do I capture stdout or stderr from a program started by StartProgram?
You cannot collect the streams through StartProgram; the method offers no output parameters. Put the capture inside the helper itself: have it write its own log file to an absolute path with startup time, resolved paths, milestones, errors and an explicit completion record. Then the HMI reads that file or a status tag instead of a console.
Which directory does a program started by StartProgram use as its working directory?
The method exposes no working-directory argument, so never let the helper resolve relative paths. Pass input, output, configuration and log locations as explicit absolute paths in the argument string, and have the helper log its resolved working directory and execution identity on the first run so you can see where it actually landed.
Can a program started by StartProgram show its window to a browser client of the runtime?
No. A browser client runs the screens, not Windows processes, and the method cannot start a program with a user interface at all. If the requirement is an interactive third-party application on screen, check the installed Unified documentation for supported integration methods rather than trying to force a hidden process onto a desktop.


