How to print a text file to an external printer from within a Wonderware Application Server script
Last updated: March 5th, 2025Description
- Author: Joe Hefner
- Published: March 5th, 2025
Details:
Description
This article from InSource walks through an approach for printing a file to an external printer from within a Wonderware Application Server script.
- Author: Joseph Hefner
- Published: 7/15/2016
- Application Server 2012 and above
Details
This approach has been tested but may not work in every scenario.
Step 1: Create an application server object and an attribute to trigger the script. In the example below, the object and script are both called PrintFile:
Step 2: Create the script to print the file. In order for this script to work, the printer you wish to print to will need to be setup as the default printer. In this example, I am using the attribute created in Step 1. In this example, the text file to be printed is located at "C:\SampleText.txt". The extra "\" in the script below is necessary for it to be passed properly from within the script:
Below is the script above in text format:
dim P1 as System.Diagnostics.Process;
dim psi as System.Diagnostics.ProcessStartInfo;
dim File as string;
P1 = new System.Diagnostics.Process();
File = "C:\\SampleText.txt";
psi = new System.Diagnostics.ProcessStartInfo(File);
psi.Verb = "PRINT";
psi.UseShellExecute = true;
psi.CreateNoWindow = true;
psi.Arguments = File;
P1.StartInfo = psi;
P1.Start();
Me.PrintFile = false;
Step 3: Save and close the object and then test triggering the print operation from within Object Viewer: