1. Overview
Plant-floor HMIs running Siemens WinCC Runtime Advanced V16 + Update 1 on a Windows PC or Panel PC frequently depend on a 4G/5G USB dongle, satellite backhaul, or a customer-supplied Ethernet connection to reach remote services (telemetry, MQTT brokers, asset dashboards, remote support VPN). When the upstream WAN link drops, operators must know within seconds — without minimizing the runtime window — that the link is down so they do not chase a non-existent PLC fault or restart healthy services.
This reference documents a complete, field-proven approach for driving a green/red internet status icon on a WinCC Runtime Advanced screen using a single internal Boolean tag updated by a VBScript action scheduled in the runtime. The article covers four detection strategies (ICMP ping, Microsoft NCSI HTTP probe, WMI adapter query, NCSI service registry read), TIA Portal tag configuration, scheduler wiring, screen animation, and a verification matrix.
2. Prerequisites
| Item | Specification |
|---|---|
| Engineering software | TIA Portal V16 Update 1 or later (HMI SP for WinCC Runtime Advanced) |
| Runtime | WinCC Runtime Advanced V16 Update 1, installed on Windows 10 LTSC 2019 / Windows 10 IoT Enterprise (x64) |
| PC platform | SIMATIC IPC, Panel PC, or any industrial PC meeting the WinCC V16 Runtime Advanced system requirements |
| WAN interface | USB 4G/5G dongle (Huawei E3372, Sierra MC7455, etc.) or Ethernet uplink with DHCP |
| Windows account | Local administrator (required to read NCSI service registry and to execute ping.exe from the WinCC action host) |
| Firewall rules | Outbound ICMPv4 to probe IP, outbound TCP 80 to NCSI endpoint, and DNS to system resolver |
| External probe targets | 8.8.8.8 (ICMP), www.msftncsi.com (NCSI HTTP), or a customer-defined site |
3. Network Status Detection Architecture
Windows reports network state on three distinct layers, and a robust HMI indicator must interrogate the layer that matches the operator's expectation. A green LED on the HMI should mean: "this PC can reach at least one well-known public service over the WAN interface in use right now."
| Layer | What it tells you | Typical API | Limitation |
|---|---|---|---|
| 1. Link / adapter | Cable plugged in, radio up, DHCP address assigned | WMI Win32_NetworkAdapter, NetConnectionStatus | Reports UP even when ISP is offline (e.g., captive portal, DNS down) |
| 2. ICMP reachability | Round-trip to a single public IP succeeds | ping.exe via WScript.Shell.Exec | Some carriers block ICMP; corporate firewalls filter it |
| 3. NCSI HTTP probe | Windows NCSI gets a valid response from a known DNS name | WinHttpRequest, MS NCSI | Closest match to the Windows network tray icon behavior |
Microsoft documents the Network Connectivity Status Indicator (NCSI) in detail; it is the same logic that drives the globe icon in the Windows system tray. NCSI performs a DNS lookup against dns.msftncsi.com, resolves it to 131.107.255.255, then issues an HTTP GET to http://www.msftncsi.com/ncsi.txt expecting the body Microsoft NCSI. NCSI also issues an ICMP ping to dns.msftncsi.com. Either active probe succeeding sets the tray icon to "connected." Replicating that behavior in VBScript gives the operator the same trust as the Windows icon.
Microsoft NCSI Overview (Windows Server docs)
4. Selecting the Probe Strategy
| Method | Detection target | Probe latency | Code complexity | Recommended use |
|---|---|---|---|---|
| ICMP ping (8.8.8.8) | Layer 3 reachability | 500–1500 ms | Low | Quick check on links where ICMP is permitted |
| NCSI HTTP probe | Layer 7 + DNS | 800–2500 ms | Medium | Most accurate; mirrors the Windows tray icon |
| WMI Win32_NetworkAdapter | Adapter link state | 50–200 ms | Low | Fail-fast check; pair with one of the above |
| Registry read of NlaSvc keys | Result of last Windows NCSI | 10–50 ms | Very low | Read-only fallback; cannot replace the probe itself |
Recommended pattern: Combine the WMI adapter check with the NCSI HTTP probe. If NetConnectionStatus = 2 (Connected) and the HTTP probe returns 200, drive the tag TRUE. This eliminates false positives when the dongle is associated with the tower but the cellular APN has lost the PDP context.
5. Method 1 — ICMP Ping via WScript.Shell
The simplest probe. WScript.Shell.Exec returns a WshScriptExec object whose StdOut is parsed for the substring TTL= that Windows ping emits on a successful reply.
' Module: mod_InternetCheck
' Purpose: Returns TRUE if the configured IPv4 host replies to ICMP echo.
' Caveat: Some LTE carriers and corporate firewalls block ICMP. Use Method 2 if
' you observe timeouts even when the link is healthy.
Const PING_TARGET = "8.8.8.8"
Const PING_COUNT = "1"
Const PING_TIMEOUT = "1000" ' milliseconds
Function PingHost(ByVal sTarget)
Dim oShell, oExec, sLine, bOK
bOK = False
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("ping -n " & PING_COUNT & " -w " & PING_TIMEOUT & " " & sTarget)
' Guard against runaway processes: 5 s hard ceiling on stdout drain.
Dim tStart : tStart = Timer
Do While oExec.Status = 0 And (Timer - tStart) < 5
WScript.Sleep 100
Loop
Do While Not oExec.StdOut.AtEndOfStream
sLine = oExec.StdOut.ReadLine
If InStr(1, sLine, "TTL=", vbTextCompare) > 0 Then
bOK = True
Exit Do
End If
Loop
Set oExec = Nothing
Set oShell = Nothing
PingHost = bOK
End Function
CreateObject("WScript.Shell") is permitted, but anti-virus on hardened plants may block ping.exe. Test from the same account the runtime will use.6. Method 2 — NCSI HTTP Probe via WinHttpRequest
This is the recommended primary probe. The NCSI text file at http://www.msftncsi.com/ncsi.txt is the same URL Windows queries; the expected body is exactly Microsoft NCSI. Set aggressive timeouts because a stalled probe will block the scheduler and freeze your tag updates.
' Module: mod_NCSIProbe
' Purpose: Replicates the Microsoft NCSI active probe. Returns TRUE only when
' DNS resolution and HTTP both succeed and the body matches.
Const NCSI_URL = "http://www.msftncsi.com/ncsi.txt"
Const NCSI_BODY = "Microsoft NCSI"
Const NCSI_TIMEOUT = 1500 ' ms (resolve + connect + send + receive)
Function ProbeNCSI()
Dim oHTTP, sBody
ProbeNCSI = False
On Error Resume Next
Set oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
If oHTTP Is Nothing Then Exit Function
oHTTP.SetTimeouts NCSI_TIMEOUT, NCSI_TIMEOUT, NCSI_TIMEOUT, NCSI_TIMEOUT
oHTTP.Open "GET", NCSI_URL, False
oHTTP.SetRequestHeader "User-Agent", "WinCC_NCSI/1.0"
oHTTP.Send
If Err.Number = 0 Then
If oHTTP.Status = 200 Then
sBody = oHTTP.ResponseText
If InStr(1, sBody, NCSI_BODY, vbTextCompare) > 0 Then
ProbeNCSI = True
End If
End If
End If
On Error Goto 0
Set oHTTP = Nothing
End Function
7. Method 3 — WMI Network Adapter Enumeration
Use WMI to confirm the cellular adapter is actually NetConnectionStatus = 2 (Connected) before trusting any application-layer probe. This stops a false green LED when the dongle is enumerated but has no IP address.
' Module: mod_WMIAdapter
' Purpose: Inspect each Win32_NetworkAdapter and return TRUE if any enabled
' adapter reports a connected link state. Optionally filter by name
' substring (e.g., the LTE dongle's friendly name).
Function AdapterConnected(Optional ByVal sNameContains = "")
Dim oWMI, oItems, oItem, bOK
bOK = False
On Error Resume Next
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!.\\root\\cimv2")
Set oItems = oWMI.ExecQuery("Select * from Win32_NetworkAdapter where NetEnabled=True")
If Err.Number <> 0 Then
AdapterConnected = False
Exit Function
End If
For Each oItem In oItems
If Len(sNameContains) = 0 Or InStr(1, oItem.Name, sNameContains, vbTextCompare) > 0 Then
If oItem.NetConnectionStatus = 2 Then bOK = True ' 2 = Connected
End If
Next
On Error Goto 0
AdapterConnected = bOK
End Function
NetConnectionStatus codes (per Win32_NetworkAdapter): 0 = Disconnected, 1 = Connecting, 2 = Connected, 3 = Disconnecting, 4 = Hardware not present, 5 = Hardware disabled, 6 = Hardware malfunction, 7 = Media disconnected, 8 = Authenticating, 9 = Authentication succeeded, 10 = Authentication failed, 11 = Invalid address, 12 = Credentials required.
8. Method 4 — Read the NCSI Service Registry (Caching Layer)
Windows NCSI writes its most recent decision to HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet. Reading these keys is near-instant and immune to the network being slow; however it does not replace an active probe, because a reboot, sleep, or a fast disconnect may leave a stale value.
' Module: mod_NCSIStatus
' Purpose: Read Windows' cached NCSI verdict. Returns "Online" or "Offline".
Function ReadNCSIStatus()
Dim oShell, sVal
On Error Resume Next
Set oShell = CreateObject("WScript.Shell")
sVal = oShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\ActiveWebProbeResult")
If Err.Number <> 0 Then sVal = "Unknown"
On Error Goto 0
ReadNCSIStatus = sVal
End Function
Typical values: ActiveWebProbeResult = active (healthy) or inactive (no NCSI). ActiveWebProbeHost = www.msftncsi.com and ActiveWebProbePath = ncsi.txt.
9. TIA Portal Configuration — Internal Bit Tag
- Open the HMI device in TIA Portal V16.
- Project tree → HMI Tags → double-click to open the tag table.
- Add a new tag:
Field Value Name InternetStatus_OKConnection Internal tag Data type BoolLength 1 Acquisition mode Cyclic continuous Update cycle 1 s (default 100 ms works for most; see verification) - Add an optional second tag for diagnostics:
InternetStatus_LastResultasWString[64]storing the textual outcome of the last probe.
10. WinCC Scheduler — VBScript Action
- Project tree → Schedules → add a new schedule (e.g.,
Sched_InternetCheck). - Set the trigger to a 5 s interval. Do not go below 2 s; the NCSI HTTP probe can take 1.5 s on cellular and you do not want overlapping invocations.
- Attach a VBScript action and paste the orchestrator below. The action sets the internal tag, never a PLC tag — the operator screen is the only consumer.
' Action: act_InternetCheck (attached to Sched_InternetCheck)
' Period: 5 s. Writes HMI internal tag "InternetStatus_OK".
Option Explicit
Dim bAdapter, bProbe, bOK, sResult
bAdapter = AdapterConnected("") ' Method 3
bProbe = ProbeNCSI() ' Method 2
bOK = (bAdapter And bProbe) ' combine
If bOK Then
sResult = "Online (" & FormatDateTime(Now, vbShortTime) & ")"
SmartTags("InternetStatus_OK") = True
Else
sResult = "Offline (" & FormatDateTime(Now, vbShortTime) & ")"
SmartTags("InternetStatus_OK") = False
End If
SmartTags("InternetStatus_LastResult") = sResult
AdapterConnected, ProbeNCSI, PingHost) must be defined in the project (Project tree → VBScripts → Modules) and visible in the action's scope. WinCC does not automatically share module-level routines across action files — import the module into the same scope as the action, or paste the helpers at the top of the action itself.11. HMI Screen — Green / Red Indication
- Open the runtime screen (e.g.,
Screen_Main). - Drop two identical circle objects (
Circle_Online,Circle_Offline) on top of each other. - For each, open Properties → Animations → Appearance and configure:
Object Tag Value range Result Circle_Online InternetStatus_OK0 = invisible, 1 = green fill (#00B050) Visible when link is up Circle_Offline InternetStatus_OK(inverted via "NOT")0 = red fill (#C00000), 1 = invisible Visible when link is down - Add a multi-line text field bound to
InternetStatus_LastResultfor an audit trail visible to operators. - Optionally add a tooltip on each circle that explains the failure mode when offline (e.g., "Dongle association lost — check signal LEDs").
The animation logic can be summarized as a small state machine:
ProbeNCSI = TRUE
+--------------------------+
| v
[Offline] --- AdapterConnected = TRUE ---> [Online]
^ |
| |
+------- ProbeNCSI = FALSE +
OR
+------- AdapterConnected = FALSE
12. Edge Cases and Field Caveats
| Symptom | Likely cause | Mitigation |
|---|---|---|
| Tag stuck TRUE after pulling the dongle | NCSI result cached, no active probe in your code | Combine NCSI probe with WMI adapter check; ignore cache unless probe has run within 30 s |
| Tag flickers every 5 s | ICMP dropped on transient packet loss | Add a 2-of-3 hysteresis: require two consecutive successful probes before clearing the offline state |
CreateObject("WinHttp.WinHttpRequest.5.1") fails |
WinCC runtime locked down by customer policy | Verify the WinCC host runs under an account with COM activation rights; check Windows Event Log → Application for DCOM errors |
| ping.exe not found | Restricted PATH in runtime service account | Use absolute path %SystemRoot%\System32\PING.EXE in Method 1 |
| DNS resolves but TCP 80 blocked | Plant proxy / firewall | Switch probe target to an internal IP that you control, or use the NCSI IP-only probe (131.107.255.255) without DNS |
| VPN in use | NCSI sees the corporate tunnel as "Internet" | Bind the probe to a specific adapter by IP, or disable NCSI for the VPN interface in HKLM\SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator\NoActiveProbe
|
| Runtime runs as SYSTEM | ICMP requires impersonation | Configure the WinCC Runtime Service to run as a named local user with network credentials |
| Tag never updates | Scheduler disabled because the screen is not visible | Set scheduler trigger to On start of runtime + Cyclic rather than On screen change |
13. Verification and Commissioning Checklist
- Compile and download the HMI project. Confirm the runtime starts in Service mode with the project autoload enabled.
- Open the screen containing the indicator. The green circle should appear within one probe cycle (≤ 5 s) of runtime start.
- Pull the USB dongle. The red circle should appear within 10 s (worst case: one cycle for adapter query, one for HTTP timeout).
- Reinsert the dongle. Confirm the green circle returns and
InternetStatus_LastResultupdates with the timestamp. - Open a CMD prompt and run
nslookup www.msftncsi.comto confirm DNS is healthy. Runcurl -v http://www.msftncsi.com/ncsi.txtand confirm the body isMicrosoft NCSI. - From the same Windows account that hosts the runtime, run
cscript //nologo "C:\Program Files\Siemens\Automation\WinCC RT Advanced\bin\WCCILpm.exe"(or open the HMI control center) and verify the schedule fires at the configured interval. - Disable the WAN link in Device Manager to confirm the offline branch fires without operator intervention.
- Tail Windows Event Viewer → Application for any COM or scripting errors during a 24 h soak test.
14. Frequently Asked Questions
Which probe target is most reliable on a cellular dongle in a plant?
The Microsoft NCSI HTTP probe (http://www.msftncsi.com/ncsi.txt) is the most reliable because it exercises both DNS and TCP. Combine it with a WMI Win32_NetworkAdapter check on NetConnectionStatus = 2 to avoid false positives when the dongle has an IP address but no PDP context.
Why is my tag stuck on TRUE after I unplug the 4G dongle?
You are most likely reading the cached NCSI registry key without an active probe. WinCC does not auto-update HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\ActiveWebProbeResult for your action. Add Method 2 (WinHTTP) or Method 3 (WMI) to your scheduled action so the verdict is regenerated every 5 s.
Can I use the same code in WinCC Professional or WinCC Unified?
No. WinCC Professional uses C / VBScript with a different runtime object model, and WinCC Unified uses JavaScript on Chromium-based runtime. The SmartTags() accessor, the CreateObject("WScript.Shell") host, and the scheduler object are specific to WinCC Runtime Advanced V16. Porting the code to Unified requires using HMIRuntime.Tags and the asynchronous fetch API.
What cycle time should I use for the scheduler?
Use 5 s for the combined NCSI + WMI approach. Faster than 2 s will overlap probes during slow LTE links and may cause COM resource exhaustion. If you need a faster operator reaction, run the WMI adapter check at 1 s and the NCSI HTTP probe at 5 s in two separate scheduled actions, each writing to its own tag.
Does this approach work when the PC is on a corporate VPN?
Yes, but the green LED will reflect VPN reachability rather than raw cellular reachability. If you must distinguish the two, filter the WMI query by adapter name (e.g., the LTE dongle's friendly name string) and only treat the cellular adapter as authoritative for the indicator.