Learning Foundation: Runtime Execution Architecture
This page has one defined job in the WinCC VBScript learning path. Master this foundation before using the same concept inside larger SCADA, SQL Server and reporting scripts.
Read/write tags and reusable functions should be understood before periodic/global execution.
Global Script determines when reusable VBS actions run. Trigger choice controls load, response time and data freshness.
Run event logging or status processing only on meaningful tag/event/cyclic triggers rather than unnecessary fast polling.
Choose event, tag and cyclic triggers and design Global Script actions with predictable execution and Runtime load.
Tag/event/cycle condition occurs
Starts the configured action
Central reusable VBS code
Read, validate, log
Confirm execution timing
Complete WinCC VBScript Learning Path
Use Previous/Next for the recommended practical order, or open any topic below as a reference.
Configure WinCC Global Script VBS Actions and Triggers
This lab targets wincc global script vbs trigger with copy-ready examples, expected results and diagnostic guidance.
1. Global Script VBS Actions Explained
A Global Script action is project-level VBS logic executed by Global Script Runtime. It is separate from a Graphics Designer object-event action. Confirm that Global Script Runtime is included in the computer startup configuration before testing.
2. Choose the Correct Trigger
| Trigger | Use | Risk |
|---|---|---|
| Tag trigger | Respond when a selected process tag changes | Noise or rapid changes may call the action frequently |
| Cyclic trigger | Periodic housekeeping or sampling | Short cycles can overload script Runtime |
| Event action | Explicit operator or picture event | Depends on the picture/object lifecycle |
3. Create a Small Traceable Global Action
Function action
Dim triggerTag
Set triggerTag = HMIRuntime.Tags("Demo_Trigger")
triggerTag.Read
HMIRuntime.Trace "Global action called, trigger=" & CStr(triggerTag.Value)
Set triggerTag = Nothing
action = 0
End Function
Easy TestEasy Test 1 — InputBox + MsgBox
Offline tag simulation: useful before connecting the participant PC to WinCC Runtime.
Dim TestValue, ResultText
ResultText = ""
TestValue = InputBox("Enter simulated value for Demo_Trigger", "Easy Test 1 — InputBox + MsgBox", "TEST")
ResultText = ResultText & "Demo_Trigger = " & TestValue & vbCrLf
MsgBox ResultText & vbCrLf & "Now compare these values with the original HMIRuntime .Read example.", vbInformation, "Tag Read Quick Test"The action signature is supplied by the editor. Keep declarations in the editor area and place only executable logic inside the generated action body.
4. Understand Separate Runtime Contexts
Global Script and Graphics Designer actions are processed independently. Do not assume an in-memory global variable written in one context is immediately shared with another. Use approved internal WinCC tags or the WinCC DataSet mechanism when state must cross contexts.
5. Trigger Performance Rules
- Use the slowest cycle that meets the real requirement.
- Do not automate Excel, query SQL or process large files in a fast cyclic action.
- Prevent overlapping work with a controlled busy-state tag where necessary.
- Trace entry, exit and errors during commissioning, then control trace volume.
Hands-On Verification Lab
Hands-onPrepare a controlled test
Create only the internal tags, folders or disposable database rows required by this tutorial.
Run the smallest example
Execute one operation and inspect WinCC diagnostics before expanding the script.
Test a failure path
Use a safe backup copy to test an invalid tag, path or disposable input.
Frequently Asked Questions
Should this WinCC VBScript be tested in production?
No. Use a backed-up training or staging project and follow the plant change-control process.
Which WinCC versions does the example target?
The examples target classic WinCC Explorer V7.x/V8.x. Verify object properties, action signatures and providers in the installed WinCC help.
How should Runtime failures be diagnosed?
Use scoped Err checks, WinCC object diagnostics and HMIRuntime.Trace while recording the exact station, trigger, tag and Runtime identity.
SQF Running Project Lab · Blog 08
Trigger the SQF logging action
Sub SaveSQFEvent()
'Read SQF tags
'Validate values
'Insert one event row
End Sub
'Call SaveSQFEvent from the approved WinCC action/trigger.
Easy TestEasy Test 2 — InputBox + MsgBox
Self-contained procedure test; no PLC or SQL Server is required.
Sub ShowSQFValue(ByVal NameText, ByVal ValueText)
MsgBox NameText & " = " & ValueText, vbInformation, "Sub Quick Test"
End Sub
Dim TempAct
TempAct = InputBox("Enter Temp_Act", "Easy Test 2 — InputBox + MsgBox", "825.5")
Call ShowSQFValue("Temp_Act", TempAct)