Testing WinCC Flexible VBScripts Offline Without a TP270 Panel
Overview
Siemens SIMATIC WinCC flexible is the legacy HMI engineering suite for the TP170, TP270, OP170, OP270, MP270, MP370, and Mobile Panel 170/270 families. The engineering station typically runs Windows XP Professional SP3 (or Windows 7 SP1 32-bit in later cycles), while the target panel hardware executes the compiled runtime on Windows CE 5.0 or Windows Embedded Compact 7. This split creates a recurring field problem: how do you validate VBScript logic when the physical TP270 10" panel is on another site, on a different machine, or simply not on the bench?
This reference documents three field-proven paths that practicing engineers use to test VBScripts offline, the prerequisites for each, the limitations that surface, and the verification steps required to sign off a script before it ships to the panel. The three methods are:
- WinCC flexible built-in simulator — Start → Start Runtime from the engineering software.
- WinCC flexible PC Runtime — installed on the engineering PC as a separate component.
- Microsoft Virtual PC 2007 SP1 — plus a Windows CE 5.0 evaluation image.
The choice depends on what the script does. Pure logic (tags, math, screen calls) is fine in the simulator. File I/O, ActiveX, and OPC need the PC Runtime. CE-only COM, registry look-ups, and panel-image extensions need the Virtual PC path. A final hardware FAT on the physical TP270 is always required for sign-off; no offline path covers touch calibration, the panel buzzer, or live fieldbus I/O.
Prerequisites
| Item | Required / Recommended | Notes |
|---|---|---|
| WinCC flexible Engineering | 2007 SP3 or 2008 SP3 / SP4 | 2008 SP4 is the final released service pack for the 2008 line |
| Engineering PC OS | Windows XP SP3 (32-bit) or Windows 7 SP1 (32-bit) | WinCC flexible 2008 is not officially supported on Windows 10 / 11 |
| Author license | Required for the built-in simulator | Bundled with the engineering software |
| PC Runtime license | Required for Method 2 (PC RT) | Separate SKU from the panel license; demo mode runs 30 days |
| RAM | ≥ 1 GB; 2 GB if running PC Runtime + Virtual PC simultaneously | Field-proven minimum for stable transfers |
| Free disk | ≥ 5 GB | For the compiler, simulator cache, and CE VHDs |
| TP270 10" target reference | 6AV6 545-0BC15-2AX0 (10.4" color TFT, 800 x 600) | Windows CE 5.0 device class |
| Virtual PC path (Method 3) | Microsoft Virtual PC 2007 SP1 | Free download; 32-bit hypervisor only |
| WinCE VHD (Method 3) | Windows Embedded CE 5.0 Evaluation VHD | Distributed by Microsoft for evaluation only |
How VBScripts Are Compiled for WinCC flexible
VBScript in WinCC flexible is stored in the project tree under two locations:
- Scripts → Project Scripts — global functions and subroutines callable from any screen.
- Per-screen Events — handlers attached to object properties (e.g.,
OnClickof a button,OnValueChangedof an IO field,OnScreenOpenof a screen).
The compiler emits Microsoft VBScript 5.x bytecode targeting one of two runtime hosts:
- Win32 target — WinCC flexible PC Runtime on Windows XP / Windows Embedded Standard.
- WinCE target — Compact Framework runtime for TP/MP panels.
The two targets diverge in three areas that frequently break naive cross-platform scripts:
-
Object model coverage: WinCE lacks
WScript.Shell, fullScripting.FileSystemObjectsemantics, and most third-party COM objects. The CE build ships a stripped VBScript host with only the core object set. -
Path conventions: TP panels use device paths like
\Storage Card\...and\Flash\..., while the PC Runtime uses conventional Windows paths underC:\Program Files\Siemens\Automation\WinCC flexible 2008\.... -
Available libraries: Date, math, and string functions are intact, but
FormatCurrency, regional settings handling, andCreateObjectcalls against unregistered COMs behave differently. The CE VBScript host coerces empty variants to empty strings more aggressively than the Win32 host.
Method 1 — Built-in Simulator (Primary Path)
The WinCC flexible engineering software includes a simulator that loads the compiled project into a hosted environment on the engineering PC. The simulator executes the project's VBScript using the host's VBScript engine — VBScript.dll version 5.8 on Windows XP SP3, or 5.812 on Windows 7 — so path and COM semantics match the Win32 target. It is the right tool for logic validation when the script uses only tags, math, and screen functions.
Procedure
- Open the project in WinCC flexible ES.
- From the Project menu, run Compiler → Start Compiler. Resolve every error and every warning. The build must complete with status "Compile completed without errors" before the simulator will launch.
- From the same menu choose Start → Start Runtime (or press
F5). The WinCC flexible RT window appears. - Operate the screen as a user would on the panel. Mouse clicks emulate touches. The on-screen keyboard appears automatically when an IO field receives focus.
- Open View → Output Window to read
HMIRuntime.Tracemessages.
Trace Helper
Add this debug function to the project's global script:
Sub Dbg(s)
HMIRuntime.Trace "DBG: " & s
End Sub
Call it from any event:
Dbg "Tag value = " & SmartTags("Level")
Dbg "Error: " & Err.Number & " " & Err.Description
What the Simulator Does and Does Not Cover
| Feature | Simulator | Real TP270 10" |
|---|---|---|
| Tag updates and arithmetic | Yes | Yes |
| Screen navigation and overlays | Yes | Yes |
| VBScript (logic, strings, math) | Yes (Win32 engine) | Yes (WinCE engine) |
| File I/O via HMIRuntime.FileSystem | PC paths | \Storage Card\ paths |
| Recipes | PC temp folder | Flash card / \Storage Card |
| Alarms with horn | Sound file on host | Panel buzzer (limited SPL) |
| PROFIBUS / MPI / PROFINET | Not exercised | Yes (panel-side) |
| Touch calibration | Mouse only | 4-point hardware calibration |
| Sm@rtService / Sm@rtAccess | PC-RT-only | Panel-side when licensed |
| Audit trail / electronic signature | Project-dependent | Panel-side; PC RT may differ |
\\Storage Card\Logs\log.txt, the simulator will fail with "Path not found" because the host has no such share. Use HMIRuntime.FileSystem only on PC-Runtime targets, and qualify file paths behind a tag-driven project constant. For CE targets, mirror the directory structure locally on the engineering PC and qualify the path with a tag like SmartTags("LogPath") that is set per project to the correct root.Method 2 — WinCC flexible PC Runtime on Windows XP
For higher-fidelity behavior — Sm@rtAccess, OPC, full file I/O semantics, and ActiveX controls — install the WinCC flexible Runtime (PC RT) on the engineering PC. This is the same runtime that ships on the panel hardware, recompiled for x86, and is the closest you can get to panel behavior without the actual panel.
Procedure
- Insert the WinCC flexible 2008 SP4 DVD and run
Setup.exe. - Select WinCC flexible Runtime 2008 as an additional installation. Do not deselect the engineering software; the PC RT can co-reside with it.
- Restart the PC. The Automation License Manager opens automatically.
- Activate the PC Runtime license. Without one, the RT runs in demo mode for 30 days with a watermark on the start screen.
- Open the project, recompile (Project → Compiler → Start Compiler), then transfer to the local PC Runtime: Start → Programs → SIMATIC → WinCC flexible → Transfer → Transfer Mode, then select Project → Transfer → PC Runtime. Use transfer mode Ethernet (TCP/IP) with target address
127.0.0.1. - Start the PC Runtime from the Start menu. It runs the same compiled project the panel would.
- Inspect runtime errors via Start → Programs → SIMATIC → WinCC flexible → Diagnostics. The diagnostic dump captures tag values, last event, and the script's VBScript host version.
Licensing Notes
- A single PC Runtime license is required per engineering PC, regardless of project count.
- A panel license (e.g., for the TP270 10") does not enable the PC Runtime; they are separate SKU lines.
- Multiple Runtime instances on the same PC are not supported; one PC = one Runtime.
- License transfer between PCs requires the Automation License Manager and a license USB stick or softcontainer.
Method 3 — Virtual PC 2007 SP1 + Windows CE Image
When the script depends on CE-only APIs (registry look-ups under [HKEY_LOCAL_MACHINE\...], file paths under \Program Files\Siemens\..., or Siemens panel-side COM extensions), use Microsoft Virtual PC 2007 SP1 with a Windows CE 5.0 evaluation VHD. This is the closest you can get to panel-side execution without panel hardware.
Procedure
- Download and install Microsoft Virtual PC 2007 SP1 on the engineering PC. Virtual PC 2007 is a 32-bit hypervisor and only runs on Windows XP or 32-bit Windows 7.
- Download the Windows Embedded CE 5.0 Evaluation Edition VHD from the Microsoft download center. Verify the SHA-1 of the VHD against the published manifest before booting.
- Launch Virtual PC. Create a new virtual machine, allocate 256 MB of RAM, and attach the CE VHD to IDE 0.
- Boot the VPC. Configure the virtual network as Bridged so the VPC receives a real DHCP address on the engineering LAN. (NAT works too, but Bridged is the most predictable for the WinCC flexible transfer protocol.)
- In WinCC flexible ES, set the project target to TP270 10", set the transfer channel to Ethernet, and set the target address to the VPC's bridged IP.
- Compile and transfer the project to the VPC. The WinCC flexible Runtime on the VPC executes the project's VBScript inside the CE VBScript host.
- Test scripts against the CE-hosted runtime. The same VBScript engine that runs on the TP270 10" will execute inside the VPC — file paths, COM object availability, and host VBScript version all match.
Caveats
- Virtual PC 2007 is a 32-bit hypervisor and is not supported on Windows 10/11. Use an older engineering PC for this path.
- The CE evaluation VHD is a generic image. Siemens-specific panel extensions (e.g., the
SiemensHMI.AudioControlActiveX, theHMI TagsCOM) are not present. Scripts that call into these will throw "ActiveX component can't create object". - The VPC approach is excellent for logic validation but limited for graphic fidelity. The Siemens panel image is custom, and the CE evaluation image is a reference build, so screen rendering, fonts, and control visuals will differ.
- For panel-side ActiveX testing, the only fully faithful path is on the physical panel. Plan for a hardware FAT window.
Testing Topology and Decision Flow
The diagram below summarizes the relationship between the engineering PC, the three test paths, and the target TP270 10".
Decision Matrix
| Script uses | Recommended method |
|---|---|
| Tags, math, screen functions only | Built-in simulator (Method 1) |
| File I/O, ActiveX, OPC | PC Runtime (Method 2) |
| CE-only COM, registry, panel-image extensions | Virtual PC + CE VHD (Method 3) |
| Hardware I/O (PROFINET, MPI, PROFIBUS) | Real panel required (no substitute) |
| Audit trail, electronic signature, 21 CFR Part 11 | Real panel in a qualified environment |
VBScript Debugging Best Practices
-
Trace instead of MsgBox:
HMIRuntime.Tracewrites to the engineering output window without blocking the script.MsgBoxhalts execution and is invisible on a WinCE panel that runs headless. -
Always wrap external COM calls:
On Error Resume Next Set fso = CreateObject("Scripting.FileSystemObject") If Err.Number <> 0 Then Dbg "FSO unavailable: " & Err.Description Err.Clear End If On Error Goto 0 -
Tag-driven path constants avoid hard-coded strings:
Dim basePath : basePath = SmartTags("PathBase") Dim logFile : logFile = basePath & "\Logs\shift_" & Format(Now, "yyyymmdd") & ".csv" -
Date math: use
DateAdd("s", offset, Now)rather than directNow + offsetto avoid integer-conversion surprises on WinCE's VBScript host. The CE VBScript host coerces date addition to aDoubledifferently than the Win32 host. -
Avoid
DoEventson WinCE: it can starve the polling loop and produce missed tag updates. Use the scheduler tag system (cyclically updating time tags) instead. -
Minimize global variable use: a global
Dimin WinCC flexible creates a single shared instance across the runtime. For thread-like behavior, use a state tag and route logic through it. -
Keep
Sub/Functionparameter types explicit: VBScript is variant-only, but document expected types in comments. This avoids type-mismatch errors at the call site rather than deep inside the routine. -
Profile in the simulator before transfer: a script that runs in < 50 ms on the engineering PC may run in 400 ms on the CE host due to JIT differences. Use
Timerin WinCC flexible to log script duration and trim hot paths.
Common Script Errors and Workarounds
| Symptom | Likely cause | Workaround |
|---|---|---|
ActiveX component can't create object: WScript.Shell |
CE target | Use HMIRuntime.Process or drop the shell call |
Path not found on \\Storage Card\Logs\
|
Mapped PC path; no such share on engineering PC | Verify project target is TP270 10"; use HMIRuntime.FileSystem on PC RT only |
| Tag value stale in simulator | Tag configured for on-change only; no event driving refresh | Set tag acquisition to Cyclic continuous in tag properties |
Permission denied writing to flash |
Storage card write-protected or full | Use internal flash in script config; check SmartTags("FreeSpace") before open |
| Script hangs at start on XP SP3 | Microsoft VM JIT issues with VBScript | Disable script debugging in Internet Options → Advanced |
| VBScript line numbers off by one | Mixed line endings (CRLF vs LF) after external edit | Re-save the script in WinCC flexible editor to normalize |
Subscript out of range on SmartTag array |
Tag array length changed after first compile | Reconnect tags after array size change; rebuild the project |
Type mismatch on HMIRuntime.Trace
|
Passing uninitialized variant | Initialize tag locally: Dim v : v = SmartTags("X")
|
Object required: HMIRuntime |
Script running outside Runtime (e.g., from command line) | Always run scripts inside the WinCC flexible RT context |
Compile warning Implicit conversion
|
Mixed string / numeric in tag write | Use CStr() / CInt() explicitly |
WinCE only: Class not registered on SiemensHMI.X |
Panel image missing the ActiveX | Verify panel firmware; re-flash image if needed |
| Recipe save fails on first call | Recipe directory not created | Add HMIRuntime.FileSystem.CreateFolder before save |
Recipe and Audit Trail Handling
Recipes and audit trails are the two most common script-driven features on the TP270 10" in regulated environments. Each has its own offline testing pitfalls.
Recipes
WinCC flexible supports single-record and array-record recipes backed by CSV files on the storage card. A typical script-driven recipe save looks like:
Sub SaveRecipe(name)
On Error Resume Next
Dim path : path = SmartTags("RecipePath") & "\" & name & ".csv"
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
Dbg "FSO failed: " & Err.Description
Exit Sub
End If
Dim ts : Set ts = fso.CreateTextFile(path, True)
ts.WriteLine "Field,Value"
ts.WriteLine "Setpoint," & SmartTags("Setpoint")
ts.WriteLine "Tolerance," & SmartTags("Tolerance")
ts.WriteLine "Operator," & SmartTags("CurrentUser")
ts.Close
Dbg "Recipe saved: " & path
On Error Goto 0
End Sub
Testing notes:
- In the simulator,
SmartTags("RecipePath")must be set to a writable directory on the engineering PC (e.g.,C:\Temp\Recipes). The TP270 panel does not have aC:\. - In the PC Runtime, the same path is honored, but file operations complete at desktop speed; panel-side card writes are 5–10x slower.
- In the Virtual PC + CE VHD path, the CE file system is case-sensitive in paths but case-insensitive in lookups. The script works unchanged, but watch for case mismatches when cross-debugging log files.
- Always test the disk full case: fill the storage card, attempt a save, and confirm the error handler logs and recovers rather than hanging the RT.
Audit Trail
Audit trails on the TP270 are configured in the project properties and written automatically by the runtime for operator actions, recipe changes, and value entries. Scripts that read or post-process the audit trail must run on the same path:
Sub ExportAuditTrail()
Dim srcPath : srcPath = SmartTags("AuditPath") & "\auditlog.csv"
Dim dstPath : dstPath = SmartTags("BackupPath") & "\audit_" & Format(Now, "yyyymmdd_hhnnss") & ".csv"
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile srcPath, dstPath, True
Dbg "Audit exported: " & dstPath
End Sub
Audit trail validation must always run on the physical panel in the qualified environment. The simulator and the PC Runtime differ in how they hash and time-stamp entries, and only the panel produces the regulatory-compliant audit log.
Performance and Memory Considerations
The TP270 10" ships with 32 MB of working memory, of which roughly 16 MB is available to the runtime after the Windows CE kernel and panel image load. Heavy VBScript usage can exhaust this. Practical limits observed in the field:
| Resource | Field limit | Symptom of exhaustion |
|---|---|---|
| VBScript code size | ≤ 2 000 lines total across project scripts | Compile error "out of memory" or runtime hang at start |
| Tag count | ≤ 2 048 external tags | Transfer failure with error 0xE0010030 |
| Recipe count | ≤ 100 entries per recipe, ≤ 20 recipes | Recipe save fails with "out of resources" |
| Alarm count | ≤ 4 000 discrete / 500 analog | Alarm view scrolls slowly; historical buffer overruns |
| Trend buffer | ≤ 100 000 samples per trend | Trend view hangs at refresh |
For performance, the relevant rules are:
- Tag update storm: on power-up the panel requests every configured tag from the PLC. With thousands of tags on a 187.5 kbps MPI link, the storm can take 30–60 s. Stagger tag acquisition groups by 100–250 ms to flatten the curve.
-
Script cycle: a script that completes in < 50 ms on the engineering PC can take 200–400 ms on the CE host. Profile with
Timer:Sub HeavyWork() Dim t0 : t0 = Timer ' ... work ... Dbg "HeavyWork took " & FormatNumber(Timer - t0, 3) & " s" End Sub -
String allocation: VBScript on WinCE is conservative with string interning. Avoid building large strings in a loop; use
Replacein place or write to a file in chunks. -
Array reuse:
ReDimwithPreserveis slow on WinCE. Pre-size arrays based on the worst case observed in the field.
Verification Procedure
After each script revision, complete this checklist before the next commit:
-
Compile clean:
Project → Compiler → Start Compilerreports zero errors and zero warnings. Fix every warning; they frequently become runtime errors on WinCE. - Simulator smoke test: Start Runtime, click every interactive element on every screen that uses the script. Confirm expected tag writes in the output window.
-
Tag boundary test: for each numeric tag used in arithmetic, set it to its min, max, and a typical value; confirm the script handles all three without overflow. Watch for
DateAddoverflow, division by zero, and integer wrap. - Error path test: force at least one error condition (bad file path, missing tag, out-of-range index) and confirm the script's error handler logs and recovers without hanging the RT.
- PC Runtime cross-check (when applicable): transfer the project to the PC Runtime and rerun the smoke test. PC RT surfaces file I/O and ActiveX errors that the simulator masks.
- Virtual PC cross-check (when applicable): transfer the project to the VPC-hosted CE runtime and rerun any script that touches CE-only APIs.
-
Performance test: on the engineering PC, run the script 1 000 times in a loop and confirm the average duration is within budget. Use
Dbgto log every 100th iteration. - Hardware FAT: when the panel is available, transfer via Ethernet, reboot the panel, and confirm the start screen loads. Run the full script suite on the physical TP270.
TP270 10" Field Commissioning
| Setting | Recommended value | Notes |
|---|---|---|
| Transfer mode | Ethernet (TCP/IP) | Avoid MPI for first transfer; the panel must be on the same subnet as the engineering PC |
| Project target device | TP270 10" Color (MLFB 6AV6 545-0BC15-2AX0) | Match the exact MLFB to avoid resolution mismatches |
| Cycle time (alarms) | 250 ms | Default is 1 s; tighten only after verifying CPU load on the S7 side |
| Time source | PLC | Avoid local panel time; PLC time is the audit-grade source |
| Touch calibration | 4-point on first power-up | Repeat after one week of operation as the resistive touch settles |
| Backup | Project backup on CF/SD card | Required before any firmware change |
| Firmware | Verify against WinCC flexible ES compatibility list | A panel with newer firmware than the ES supports will refuse to start the RT |
| Storage Card path | \Storage Card\ | Read/write limit ~10^5 cycles; do not log every second here |
| Power-on delay | 3 s after DC OK | Below 2 s the panel may miss the start screen and fall into recovery |
| Display brightness | 70 % for indoor, 100 % for sunlight | Set once; not scriptable on TP270 |
Edge Cases and Field Caveats
- TP270 10" with 32 MB memory: large VBScripts (> 2 000 lines) and big recipe databases can exhaust the heap. Move heavy logic to the S7 CPU and keep the HMI scripts as thin wrappers.
- Cold-start tag update storm: on power-up, the panel requests every configured tag from the PLC. With thousands of tags, this can flood a 187.5 kbps MPI link. Stagger tag acquisition groups by 100–250 ms.
- Time-zone drift: the TP270 does not include a battery-backed RTC in all variants. On panel reboot, the clock resets to 2000-01-01. Always read the time from the PLC.
-
Storage card removal mid-write: a pulled CF card during a recipe save can corrupt the FAT. Add a
WriteFilewrapper that copies to a.tmpextension and renames atomically. - Heat near the panel: TP270 10" has a 0–50 °C operating range. In cabinets above 40 °C, the backlight inverter may flicker, which is mistaken for script issues. Check the cabinet temperature first.
- Long tag names from migrated projects: importing a project from WinCC flexible 2004 into 2008 may surface tag names longer than 32 characters. The compiler truncates silently on the panel. Rename tags to ≤ 24 characters before commissioning.
- Network address collision: when multiple panels share a subnet, IP conflicts only surface at transfer time. Use DHCP with reservations, not static IPs, for service simplicity.
HmiRuntime replaces HMIRuntime in TIA Portal; tag access is via HmiRuntime.Tags rather than the global SmartTags collection).Migration to TIA Portal (For Reference)
When the TP270 must be replaced, TIA Portal's WinCC is the successor. The migration path from WinCC flexible 2008 to TIA Portal V17 / V18 is mechanical for most projects:
- Open the WinCC flexible project in TIA Portal via Project → Migrate project. TIA Portal handles the device swap, tag mapping, and screen conversion.
- Review the migration report. Common adjustments:
HMIRuntime→HmiRuntime,SmartTags("X")→HmiRuntime.Tags("X").Read/.Write, file system paths adjusted to the new OS. - Retest the scripts using TIA's built-in simulator (which uses the same Win32 VBScript engine pattern).
- Re-FAT on the new Comfort Panel hardware (e.g., TP900 Comfort, 6AV2 124-1MC01-0AX0).
The TP270 10" maps cleanly to the TP900 Comfort 9" for most recipes, screen counts, and tag counts. For larger applications, the TP1200 Comfort 12" is the recommended replacement.
FAQ
Can I run WinCC flexible 2008 on Windows 10 or 11?
Officially no. Siemens supports Windows XP SP3 and Windows 7 32-bit. Compatibility mode can get the engineering software running, but the Automation License Manager and the transfer channel drivers are unstable on newer Windows versions. Use a dedicated Windows XP SP3 or Windows 7 32-bit engineering PC for development, and a separate Windows 10/11 PC for source control and code review.
Do I need the physical TP270 to do a final FAT?
Yes. The simulator and the PC Runtime cannot validate touch calibration, brightness, the panel buzzer, real PROFIBUS / MPI / PROFINET communication, or panel-specific ActiveX. Always reserve a hardware FAT window for the final acceptance and sign off the commissioning report on the panel itself.
Why does the simulator execute the script as Win32 when my project target is WinCE?
The simulator's purpose is to test logic, not the runtime container. It uses the host PC's VBScript engine, so file paths and CE-only COM objects are mocked or unavailable. For final CE-side validation, use Method 3 (Virtual PC + CE VHD) or the real panel.
Can I test OPC client scripts in the simulator without a real PLC?
Yes. Pair the engineering PC with S7-PLCSIM (V5.4 SP3 or later) and use the WinCC flexible channel "SIMATIC S7 MPI/DP" with the PLCSIM driver. This gives you a full simulated S7-CPU on the same PC, visible to the PC Runtime over MPI/DP. The S7-PLCSIM is a Siemens product and can be obtained via the official Siemens support channels.
What is the difference between the TP270 and the MP270?
The TP270 is a touch-only panel — the keys are not functional for operator input. The MP270 includes a 36-key mechanical membrane on the right side for direct key input. Both run Windows CE 5.0 and use the same WinCC flexible runtime, so scripts developed for one run unchanged on the other, with the only difference being which events are wired to the additional key inputs on the MP270.
What is the most common reason a script that works in the simulator fails on the real TP270?
File path differences. A path like \\Storage Card\Logs\shift.csv is unreachable on the engineering PC, so the simulator never sees the path-resolution error. On the panel, the Storage Card slot is mapped to \Storage Card\, and the path works — unless the card is write-protected or full. Always use a tag-driven path base and add a free-space check before opening a file for write.