Problem Overview
When a VBScript routine developed on an engineering laptop is migrated to a SCADA runtime station, the PDF print command silently fails even though the same code path executes successfully on the development machine. The symptom pattern is consistent across reported cases:
- Environment: SIMATIC WinCC Professional V16 SP1 (TIA Portal), Windows 10 (both engineering and runtime PCs).
- Trigger: Button-click VBScript that invokes a PDF file for printing via
Shell.ApplicationorInvokeVerb. - Symptom: No print job is generated on the SCADA PC; no VBScript runtime error is raised; GSC diagnostics window reports no fault.
- Observation: The PDF opens correctly when the verb is changed from
printtoopen, which confirms the file path and VBS host are functional.
The defect is not in the VBScript itself but in the operating system's file association for the .pdf extension on the runtime PC. The WinCC Runtime VBScript host uses the registered verb handler to dispatch the print request, and without a properly registered PDF application with a print verb, the call resolves to a no-op.
Root Cause: Missing or Unregistered PDF Print Verb
Windows shell file associations are stored per-user and per-system in the registry under HKEY_CLASSES_ROOT\.pdf and HKEY_CLASSES_ROOT\.pdf\shell\print\command. When a SCADA PC is built from a clean image, no PDF viewer is installed, so the print verb is unregistered. The VBScript line:
objShell.ShellExecute "C:\Reports\DailyReport.pdf", "print", "", "print", 0
or the equivalent objFile.InvokeVerb("Print") returns silently because the verb cannot be resolved. The same script executes correctly on the engineering laptop because the developer's image has Adobe Acrobat Reader DC installed and registered as the default .pdf handler with an enabled print verb.
This root cause is documented across multiple Siemens Knowledge Base entries covering WinCC RT Professional VBScript limitations: the VBS host does not embed a PDF rendering engine, and the runtime depends entirely on the OS-level file association. The fix requires installing a PDF viewer that registers a print shell verb, then assigning it as the default handler for .pdf files.
Environment Prerequisites
| Component | Required Version | Notes |
|---|---|---|
| SIMATIC WinCC Professional | V16 SP1 or later (V17, V18, V19, V20) | All versions share the same VBScript host and shell integration model |
| SIMATIC WinCC Runtime Professional | Matching RT version installed on SCADA PC | RT must be licensed and running |
| Operating System | Windows 10 LTSC 2019 / Windows 10 IoT Enterprise 2019 / Windows Server 2016 or 2019 | WinCC V16 RT Pro is certified on these builds |
| PDF Viewer | Adobe Acrobat Reader DC (latest continuous track) or Foxit Reader | Must register shell verbs on install |
| User Account | Same Windows user that runs the WinCC RT process | File associations are user-scoped |
Solution: Install and Bind the Default PDF Handler
- Verify the engineering PC has a working PDF handler. Open the PDF manually from File Explorer, right-click, and confirm that the context menu contains a Print entry. If this is absent, install or repair Adobe Acrobat Reader DC.
-
Install Adobe Acrobat Reader DC on the SCADA PC. Use the offline installer (
AcroRdrDC*.exe) so no internet connection is required on the SCADA host. During installation, accept the default options; the installer registersAcroRd32.exeas the shell handler for.pdf. -
Set Acrobat Reader DC as the default application for
.pdffiles. In Windows Settings → Apps → Default Apps → choose default by file type, locate.pdf, and assign Adobe Acrobat Reader DC. Alternatively, right-click any PDF on the SCADA PC, select Open with → Choose another app, enable Always use this app, and pick Acrobat Reader DC. -
Confirm the print verb is registered. Open
regeditand inspectHKEY_CLASSES_ROOT\AcroExch.Document.DC\shell\print\command. The default value should contain"C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /t "%1". The/tflag triggers the print dialog sequence thatShellExecute printrelies on. - Restart the WinCC Runtime so that the shell COM objects re-initialize against the new file associations.
- Re-test the button-click VBScript. The PDF should now spool to the configured default printer without code changes.
Alternative: Use ShellExecute with Explicit Verb
If installing a third-party PDF reader is not permitted in a locked-down SCADA environment, the ShellExecute call can explicitly pass the verb string rather than rely on the default verb resolution:
' WinCC RT Professional VBScript - print PDF explicitly
Dim objShell, strPdfPath
strPdfPath = "C:\Reports\DailyReport.pdf"
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute strPdfPath, "", "", "print", 0
Set objShell = Nothing
When the verb is passed as the fourth argument, Windows still requires a registered handler for that verb. If no PDF reader is installed, this code returns silently with no error — which is the same symptom as a missing association. The only durable fix is registering a viewer.
Alternative: Use InvokeVerb on a Folder Object
The original failing script typically uses the FolderItem.InvokeVerb interface:
Dim objShell, objFolder, objFile
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace("C:\Reports")
Set objFile = objFolder.ParseName("DailyReport.pdf")
objFile.InvokeVerb "Print"
Set objFile = Nothing
Set objFolder = Nothing
Set objShell = Nothing
This method invokes the shell verb on a parsed FolderItem. The verb Print must be present in the handler's verb table. After installing Acrobat Reader DC, this approach becomes the preferred path because it integrates with the shell's IContextMenu implementation rather than relying on ShellExecute's shorter verb resolution.
Diagnostics with HMIRuntime.Trace
When a WinCC Runtime VBScript silently fails, the first diagnostic step is to enable the trace output. WinCC RT Professional provides the HMIRuntime.Trace object family that writes messages into the GSC (Global Script Console) diagnostics window and to the trace log. The relevant trace sinks are:
| Trace Function | Output Target | Typical Use |
|---|---|---|
HMIRuntime.Trace |
GSC diagnostics window "Print job/Script diagnostics" | Default channel for HMIRuntime.Trace output |
HMIRuntime.TraceSel |
GSC diagnostics window only | Filtered selection of trace lines |
HMIRuntime.TracePar |
Parameter dump | Inspects current process tags |
Reference: Example of configuring a diagnostics output via a trace (RT Professional) in the TIA Portal V20 documentation set.
A debug-instrumented version of the print script:
HMIRuntime.Trace "Print script entered, file: " & strPdfPath
On Error Resume Next
Err.Clear
Set objShell = CreateObject("Shell.Application")
If Err.Number <> 0 Then
HMIRuntime.Trace "Shell.Application create failed: " & Err.Description
On Error Goto 0
Exit Sub
End If
If Not objFolder.IsFileSystem Then
HMIRuntime.Trace "Folder is not a file system folder"
Exit Sub
End If
If Err.Number <> 0 Then
HMIRuntime.Trace "Shell invoke failed: " & Err.Description
Else
HMIRuntime.Trace "Shell invoke returned without error"
End If
On Error Goto 0
To surface the trace output during runtime:
- In TIA Portal, open the WinCC RT Professional project and add a Global Script diagnostics window to the active screen. The object is available from the toolbox under Controls → WinCC RT Professional → Diagnostic.
- Assign the diagnostic window to a screen layer that is always visible (e.g., a maintenance overlay triggered by an admin tag).
- Compile and download the project to the runtime, then trigger the print button. The trace lines appear in the diagnostic window in the order they were emitted.
- If the trace shows the script reached the
Shell.Applicationcall but no print job appears, the issue is downstream of the script (file association or printer).
Verifying the Default Printer and Spooler
After confirming the file association, verify that the SCADA PC has a usable default printer:
- Open Devices and Printers in Control Panel and confirm at least one printer shows as Ready.
- Open Print Management (or
printmanagement.msc) and ensure the Print Spooler service is running and set to Automatic. - From the SCADA runtime, manually open any PDF and choose File → Print. Confirm the spooler receives the job.
- If the SCADA PC uses a network printer, verify the print queue is reachable and the printer driver is installed locally. WinCC VBS
ShellExecute printwill dispatch to whatever Windows considers the default printer.
WinCCExplorer.exe under a service account), the default printer for that user profile may be unset, even if the interactive user has a default printer. Configure the default printer inside the service account's profile using printui /y /n "PrinterName" from a runas session, or via a startup script that calls SetDefaultPrinter.Troubleshooting Matrix
| Symptom | Likely Cause | Remediation |
|---|---|---|
No print, no error, file opens with InvokeVerb("Open")
|
Print verb not registered for .pdf
|
Install Adobe Acrobat Reader DC and set as default for PDF |
| No print, error 0x800704C9 "No application is associated" | No PDF handler installed at all | Install any PDF viewer that registers a print verb |
No print, script never reaches Shell.Application
|
Earlier On Error Resume Next swallowed exception |
Remove On Error Resume Next during commissioning and re-test |
| Print dialog appears but no document prints | Print spooler stopped or printer offline | Restart Print Spooler service, set printer to Use Printer Offline off |
| Prints on engineering PC but not on SCADA PC with same image | SCADA image missing reader or association registry keys | Re-run PDF reader install in the runtime user context |
| VBScript triggers but Adobe Reader opens to the start screen instead of printing | Adobe Reader protected mode blocks /t command | Disable Protected Mode at startup, or use /p / /h switches with caution |
| Prints once then stops until PC reboot | Adobe Reader instance lock | Close reader process via taskkill /im AcroRd32.exe /f after each print |
Best-Practice Code Template
The following template is field-tested for WinCC RT Professional V16 and later. It isolates each failure mode with a trace line and supports both file-existence and association checks:
' ----- WinCC RT Professional VBScript: robust PDF print -----
Const ForReading = 1
Dim objFSO, objShell, objFolder, objFile, strPdfPath
strPdfPath = "C:\Reports\DailyReport.pdf"
HMIRuntime.Trace "[PrintPDF] entered, target=" & strPdfPath
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strPdfPath) Then
HMIRuntime.Trace "[PrintPDF] FAIL file not found"
Set objFSO = Nothing
Exit Sub
End If
On Error Resume Next
Set objShell = CreateObject("Shell.Application")
If Err.Number <> 0 Then
HMIRuntime.Trace "[PrintPDF] FAIL Shell.Application: " & Err.Description
On Error Goto 0
Exit Sub
End If
Set objFolder = objShell.NameSpace(objFSO.GetParentFolderName(strPdfPath))
If Err.Number <> 0 Or objFolder Is Nothing Then
HMIRuntime.Trace "[PrintPDF] FAIL NameSpace: " & Err.Description
On Error Goto 0
Exit Sub
End If
Set objFile = objFolder.ParseName(objFSO.GetFileName(strPdfPath))
If Err.Number <> 0 Or objFile Is Nothing Then
HMIRuntime.Trace "[PrintPDF] FAIL ParseName: " & Err.Description
On Error Goto 0
Exit Sub
End If
objFile.InvokeVerb "Print"
If Err.Number <> 0 Then
HMIRuntime.Trace "[PrintPDF] FAIL InvokeVerb: " & Err.Description
Else
HMIRuntime.Trace "[PrintPDF] OK invoked Print verb"
End If
On Error Goto 0
Set objFile = Nothing
Set objFolder = Nothing
Set objShell = Nothing
Set objFSO = Nothing
Deploy this template, capture the trace output in the GSC diagnostics window, and confirm each branch resolves correctly on the SCADA PC.
Frequently Asked Questions
Why does my WinCC VBScript print a PDF on my engineering laptop but not on the SCADA PC?
The WinCC Runtime VBScript host depends on the Windows shell file association for .pdf. Engineering laptops typically have Adobe Acrobat Reader DC installed with the print verb registered, while clean SCADA images do not. Install Acrobat Reader DC and set it as the default app for .pdf on the runtime PC, then restart the WinCC Runtime.
Do I need to install the full Adobe Acrobat Pro, or is Reader DC sufficient?
Adobe Acrobat Reader DC is sufficient. It registers the AcroExch.Document.DC shell handler with both open and print verbs. Pro is only required if your workflow needs advanced PDF manipulation (XFA forms, prepress, or scripted automation).
How do I enable GSC diagnostics output for WinCC RT Professional VBScripts?
Place a Global Script diagnostic window on the runtime screen and call HMIRuntime.Trace "message" in your VBScript. Trace messages appear in the "Print job/Script diagnostics" object during runtime. See the TIA Portal V20 documentation for the full example: Configuring a diagnostics output via a trace (RT Professional).
Can I print PDFs from WinCC without installing any third-party PDF reader?
No. The VBScript ShellExecute and InvokeVerb paths both rely on a registered shell handler with a print verb. Windows does not ship a built-in PDF renderer. You must install a viewer such as Adobe Acrobat Reader DC, Foxit Reader, or SumatraPDF that registers the required verbs.
Does this solution apply to WinCC V17, V18, V19, and V20 as well?
Yes. The shell integration model for HMIRuntime and Shell.Application in WinCC RT Professional has remained consistent from V16 through V20. The same file-association root cause applies across all these versions, and the same Acrobat Reader DC fix works without changes.