Resolving WinCC RT Professional Client Script Tag Write Errors
Problem Overview
Engineers deploying Siemens WinCC Runtime Professional on a distributed Server/Client topology in TIA Portal v17 (and matching versions v18, v19, v20) frequently observe the following failure pattern:
- A C script that calls
GetTagChar()andSetTag()executes correctly on the Runtime Server. - The same script on a Runtime Client succeeds for a small subset of tag writes and silently fails for the majority.
- No compiler errors are reported when the script is generated in the engineering station.
- No application-level exception is raised; the script simply does not deliver the value to the PLC.
This is a classic intermittent failure mode caused by differences in script execution context, tag binding, and client-server session handling. Sporadic tag write failures of this kind are not a defect in the script source code; they are a configuration or environment issue at the client runtime layer.
Affected Environment and Versions
| Component | Verified Version(s) | Notes |
|---|---|---|
| TIA Portal | V17, V17 Update 4+, V18, V18 Update 2+, V19, V19 Update 1+, V20 | Script runtime engine is functionally equivalent across V17–V20 for this symptom. |
| WinCC RT Professional (Server) | V17.0.x / V18.0.x / V19.0.x / V20.0.x | Server side typically behaves correctly. |
| WinCC RT Professional (Client) | Same as Server | Where the failure manifests. |
| SIMATIC S7-1500 / S7-1200 PLC | Firmware V2.9+ (S7-1500), V4.5+ (S7-1200) | Tag source for the script. |
| Windows OS | Windows 10 LTSC 2019/2021, Windows Server 2016/2019/2022 | Required for both server and client installations. |
| .NET / WinCC ODK | Corresponding RT Professional minor build | ODK must be installed on the engineering station; runtime engines are bundled with RT Professional. |
Root Cause Analysis
The sporadic behavior is rarely a single defect. It is usually the combination of several root causes ranked by frequency in field reports:
-
Missing or stale client project on the target computer. The Runtime Client loads the project from a configured server share or from a local copy. If the local project is older than the server, the tag references used by the script may no longer exist on the PLC, so
SetTag()writes to a tag that points to the wrong address, or to a tag that was renamed on the server side. - Client launch mode not set to "Client with its own project." If the client is started in the wrong mode (e.g., server mode by accident, or as a WebNavigator client when a native client is required), the script runtime environment differs from the documented server behavior.
- WebNavigator-specific restrictions on user-defined functions. According to the official TIA Portal WinCC documentation, "user-defined functions may contain unsupported functions and in this case cannot run on the WebNavigator client." This applies to both C and VB scripts that call into user DLLs, COM components, or unsupported ODK APIs.
- Tag update direction / write permission mismatch. Tag objects in the HMI tags editor may have the Acquisition mode set to "On demand" with read-only access, or the Write permission may require an active user login on the client. Unauthenticated client sessions silently drop the write.
-
Asynchronous execution timing on the client. The script engine on the client schedules scripts on the same dispatch loop as graphics rendering. If the script is fired in a screen-object event (e.g.,
OnClick), the underlying tag value may not have completed the round-trip to the server before the nextSetTag()call. The server, with less load, masks this race condition. - Display script errors disabled. By default, the Runtime Client suppresses runtime script errors. The script appears to "succeed" when in fact an internal call has been swallowed.
Reference: Using Scripts (RT Professional) - WinCC.
Diagnostic Procedure
Run the following checks in order. Each step produces a verifiable output, so do not skip ahead.
Step 1 – Enable script error display on the client
On the Runtime Client computer, open the WinCC RT start application. Navigate to the runtime configuration and enable "Display script errors". Restart the runtime so the change is loaded. Reproduce the failure. Any C script runtime exception (HRESULT failure, NULL pointer, unsupported API call) will now be reported in a message box and written to the diagnostic log.
Step 2 – Compare project files on server and client
On the server, locate the active runtime project directory (default: C:\Program Files\Siemens\Automation\WinCC RT Professional\Projects\<ProjectName>\). On the client, compare the locally loaded project. The most reliable check is a hash comparison of the *.db archive and the ConfigurationFiles folder. Any mismatch means the client is running a stale project.
Step 3 – Inspect WinCC_Sys log files
Open the WinCC diagnose folder on the client:
C:\ProgramData\Siemens\Automation\Logfiles\WinCC_Sys_<ComputerName>_<Timestamp>.log
Filter for the time window when the script fired. Look for entries such as SCADA_PB: tag write denied, Authentication required, Tag not found in address space, or Script engine: HRESULT 0x80070005. The HRESULT 0x80070005 (E_ACCESSDENIED) is a direct match for tag write permission issues.
Step 4 – Confirm connection path on the client
In the client project, verify that the HMI connection to the PLC is set to "Always" rather than "On demand" for the tags touched by the script. "On demand" tags are only resolved when the HMI screen is loaded, which can lead to SetTag() returning without writing if the connection is currently suspended.
Step 5 – Validate tag quality codes
From the engineering station, in the script, add a temporary diagnostic line that calls GetTagQuality() for each tag touched. Quality codes such as 0x0000001C (Bad_OutOfService), 0x00000014 (Bad_DeviceNotConnected), or 0x00000040 (Bad_NotInitialized) explain exactly why SetTag() failed without raising an exception.
Solution
The fix is procedural, not a code rewrite. Apply the following actions:
- Re-deploy the project to the client. From the engineering station, use Compile > Software (rebuild all), then transfer the complete runtime project to the client. Do not transfer only the HMI tags file; the script compilation output and configuration files must match the server version.
- Configure the client launch mode. On the client machine, in WinCC RT start, set the project mode to "Client with its own project" and enter the server's project path. Tick the option "Server project on remote computer" if the project is loaded over the network.
-
Switch to VB Script or consolidate writes. The original suggestion from the field — using VB Script for simple read/write operations — has merit: VB Script on the client tends to surface errors more clearly. For multi-tag writes, the recommended pattern is to bind the tags to a screen or to a script-side buffer and write once, instead of issuing sequential
SetTag()calls inside a tight loop. - Enable write permission on the target tags. In the engineering station, open HMI tags > <TagName> > Properties > Properties > Write permission and ensure the tag accepts writes from any user, or that the script runs in a context where a valid user is logged in.
-
Add explicit synchronization. If the C script fires from a screen event, use
SetTagWait()instead ofSetTag()for the critical write, or wrap the multi-tag write in a single VB Script call that the C script invokes viaHMIRuntime.Screens("Screen_1").ScreenItems("Button_1").Click()or a directPDLRT.SetTagValuecall through the ODK. -
Avoid unsupported APIs in user-defined functions. Per the official documentation, user-defined functions in C or VB that call Win32 APIs, external COM objects, or ODK functions not whitelisted for the client will silently fail on a WebNavigator client. Refactor these into VB global modules and use only
HMIRuntime.TagsandHMIRuntime.Screensobjects.
Reference: Differences to the WinCC Basic System – Using Scripts (RT Professional).
Verification
After the corrective actions, perform the following to confirm the fix is stable:
- Click the button on the Runtime Client that triggers the script. Repeat the action 20 times in a row. All tag writes should succeed.
- Read the tags back from the PLC with the engineering client's online view. Values must match the expected script output for every iteration.
- Close and re-open the Runtime Client, then repeat the test. A correct deployment survives a client restart.
- Reboot the client computer. Repeat the test. This catches cases where the project was loaded from a temporary cache.
- Inspect
WinCC_SysandWinCC_RTlogs for the entire test window. No script error entries should be present.
Workarounds for Constrained Environments
If the project cannot be redeployed immediately, the following workarounds reduce the symptom but do not replace the corrective actions above.
| Workaround | Effect | Limitation |
|---|---|---|
| Run the script only on the server and use tag multiplexing | Eliminates the client script runtime entirely. | Server becomes a single point of failure. |
| Move the logic into a PLC function block | Removes dependency on HMI script engine. | Requires PLC program access and re-commissioning. |
Use a direct faceplate property binding instead of SetTag()
|
Avoids the script engine path. | Limited to the scope of the faceplate tags. |
| Force a project reload on every client restart | Ensures the client always has the latest project. | Slow startup; not scalable. |
Best Practices for Distributed WinCC RT Professional Systems
- Single source of truth. Always deploy the runtime project from the engineering station to the server, then propagate to clients. Do not edit the runtime project directly on the server or the client.
- Versioned project archives. Use TIA Portal's project versioning (introduced in V17) to track which client received which build. A failed write on a client running build N−1 against a server on build N is a configuration drift issue, not a script bug.
-
Centralized logging. Forward WinCC_Sys logs to a SIEM or a network share. The default
C:\ProgramData\Siemens\Automation\Logfiles\path is local; in a distributed system, this hides client-side errors from the engineer sitting at the server. - Default deny on write permission. Configure tags to require an authenticated write. This makes a missing login visible (the tag value is unchanged) instead of silently dropping the write.
- Test on the slowest expected client. Race conditions in script execution scale with the client CPU load. A test that passes on a development workstation may fail on a thin client in the field.
-
Use
SetTagWait()only when blocking is acceptable. The blocking variant can hold the client UI thread for up to 5 seconds (default timeout). In a fast click sequence, this introduces its own race condition.
Troubleshooting Matrix
| Symptom | Likely Cause | Diagnostic | Action |
|---|---|---|---|
| Some tags written, most are not | Stale client project, missing tags on client side | Compare ConfigurationFiles between server and client |
Redeploy project to client |
| All tags not written, no error | Tag write permission missing on client | Inspect WinCC_Sys for HRESULT 0x80070005
|
Set tag write permission / log in user |
| Intermittent, only under load | Race condition between tag reads and writes | Add GetTagQuality() diagnostics |
Use SetTagWait() or batch writes |
| WebNavigator client only | Unsupported API in user-defined function | Compare script against WebNavigator compatibility list | Refactor to whitelisted APIs |
| All clients fail, server works | Connection or authentication on client side | Check HMI connection in client project | Set connection to "Always" and confirm credentials |
| Failure only after PLC restart | Subscription not re-established | Check OnError events in the script |
Add explicit reconnect logic in script |
FAQ
Why does my WinCC RT Professional C script work on the server but fail on the client?
The C script engine on the client runs in a different process context, may load a stale project, and enforces stricter rules for user-defined functions. Typical causes are tag write permission, connection mode (On demand vs. Always), and unsupported API calls in user-defined C functions.
Should I rewrite the script in VB Script to fix the issue?
Switching to VB Script often clarifies the problem because VB Script surfaces more error information. However, the underlying cause is usually a configuration or permission issue, not the language. Use VB Script as a diagnostic step first, then fix the root cause.
How do I enable script error messages on a WinCC RT Professional client?
Open the WinCC RT start application on the client computer, navigate to the runtime configuration, enable Display script errors, and restart the runtime. Runtime exceptions are then logged to WinCC_Sys in C:\ProgramData\Siemens\Automation\Logfiles\.
What HRESULT indicates a write permission failure in WinCC RT Professional?
HRESULT 0x80070005 (E_ACCESSDENIED) is the standard return code for a tag write rejected because the current user does not have write permission, or because the tag is configured as read-only on the client side.
Can WinCC RT Professional client scripts call ODK or external DLL functions?
On a native client, a limited subset of ODK functions is supported. On a WebNavigator client, user-defined functions that call external APIs are not supported and will fail silently. Refactor such logic into a server-side global script and expose the result through a tag that the client reads.