IBM 3270 (ws3270) Custom Launcher
This topic describes how to configure ws3270 as a custom process launcher in secret-server for IBM zOS and iSeries (AS/400) host access.
Overview
ws3270 is a scriptable IBM 3270 terminal emulator included in the x3270 suite. It opens a TN3270 or TN3270E telnet session to an IBM host (zOS mainframe or iSeries / AS/400 system) and allows a script to automate the login sequence, making it well-suited for integration with secret-server as a process launcher.
Unlike interactive 3270 emulators, ws3270 is designed exclusively for scripted (headless) use. secret-server supplies the credentials at launch time via command-line parameters and the built-in -loginmacro mechanism, so the user never sees or types the password.
This guide covers:
-
Distributing ws3270.exe to workstations from the secret-server installation directory
-
Creating a Process Launcher in secret-server
-
Using the
-loginmacrooption to automate credential entry -
Associating the launcher with a Secret Template
-
Reference tables for common command-line arguments and macro actions
Prerequisites
ws3270.exe Distribution
ws3270.exe is bundled with the secret-server installation and is located in the secret-server application directory on the web server, typically at:
C:\inetpub\wwwroot\SecretServer\
The executable must be present on every workstation that will use the launcher. Distribute it using one of the following methods:
-
Group Policy Software Installation (GPO)
-
SCCM / Microsoft Endpoint Configuration Manager
-
Intune Win32 App deployment
-
Manual copy to a standard path agreed upon within your organisation
C:\Program Files\Delinea\ws3270\ws3270.exe.Network and Host Connectivity
Workstations must be able to reach the target IBM host over TCP on the TN3270 port. The default port is 23 (standard Telnet). Encrypted connections using TLS typically use port 992. Confirm the correct port with your mainframe or iSeries administrator.
secret-server Version
A secret-server version that supports custom Process Launchers is required. The launcher configuration described here applies to secret-server 10.x and later, including cloud-hosted instances. Confirm that the Protocol Handler (launcher agent) is installed on the end-user workstations.
Step 1: Creating the Custom Launcher
-
Log in to secret-server as an administrator.
-
Navigate to Secret Templates.
-
Click the Launchers tab at the top of the page.
-
Click the Create button. The New Launcher page appears.
-
In the Launcher Type dropdown, select Process. This type launches the specified executable directly on the user's machine and substitutes
$VARIABLEtokens with values from the secret at runtime. -
In the Launcher Name field, enter a descriptive name, for example:
IBM 3270 - zOS LoginorIBM 3270 - iSeries Login. -
Ensure the Active checkbox is selected.
-
In the Windows Process Name field, enter the full path to ws3270.exe on the client workstation:
C:\Program Files\Delinea\ws3270\ws3270.exe -
In the Process Arguments field, enter the command-line arguments. A typical configuration for an iSeries or zOS host is:
-model 3279-2 -charset us-intl $MACHINE $PORT -loginmacro "Wait(InputField) String($USERNAME) Tab() String($PASSWORD) Enter()"Adjust-modeland-charsetto match your host configuration. See the Command-Line Arguments Reference section for details. For TLS-encrypted connections, prependL:to the hostname token:L:$MACHINE. -
If your login screen requires additional keystrokes (for example, pressing Enter after the initial screen before the username field appears), extend the macro accordingly. Refer to the Macro Commands Reference section.
-
Select Wrap custom parameters with quotation marks if your environment requires this to prevent parameter injection.
Enabling this option adds quotes around each$VARIABLE, which may interfere with the-loginmacroargument; test carefully. -
Click Save. The new launcher is created and appears in the launcher list.
Step 2: Using the Built-in Secret Template
secret-server ships with built-in Secret Templates for both iSeries (AS/400) and zSeries (zOS) host types. A custom template does not need to be created. Use the appropriate out-of-box template when creating secrets for IBM hosts.
| Platform | Built-in Template Name |
|---|---|
| IBM iSeries / AS/400 | IBM iSeries Mainframe |
| IBM zOS / Mainframe | z/OS Mainframe |
Both templates include the Machine, Username, and Password fields required by the ws3270 launcher. Proceed to Step 3 to map the launcher to the chosen template.
Step 3: Associating the Launcher with a Secret Template
-
Navigate to Secret Templates and open the target template.
-
Click the Mapping tab.
-
Click Add Mapping. A configuration popup appears.
-
In the Launcher dropdown, select the launcher created in Step 1 (for example,
IBM 3270 - zOS Login). -
Map the template fields to the launcher parameters as follows:
Launcher Parameter Template Field $MACHINEMachine $USERNAMEUsername $PASSWORDPassword $PORTPort (set a default value of 23 if desired) -
Click Save to confirm the mapping.
The launcher is now associated with the template. Any secret based on this template will display a Launch button that starts ws3270 and automatically logs in using the credentials stored in the secret.
Using Macros for Automated Login
Overview of the -loginmacro Option
The -loginmacro command-line option accepts a space-separated sequence of ws3270 actions that run immediately after the connection is established. This is the primary mechanism for injecting credentials without user interaction.
The general syntax is:
-loginmacro "Action1(args) Action2(args) Action3(args)"
Each action is executed in order. Actions that communicate with the host (such as Enter or String) automatically wait for the host to respond before the next action runs, unless the aidWait toggle is cleared.
Basic Login Macro Example
The following example covers the most common login flow: wait for the screen to accept input, type the username, tab to the password field, type the password, and press Enter.
-loginmacro "Wait(InputField) String($USERNAME) Tab() String($PASSWORD) Enter()"
Where $USERNAME and $PASSWORD are replaced by secret-server with the values from the secret at launch time.
iSeries (AS/400) Login Macro Example
iSeries login panels often display a sign-on screen that requires pressing Enter once to dismiss an initial banner, followed by entering credentials on the sign-on panel. A macro for this scenario:
-loginmacro "Wait(InputField) Enter() Wait(InputField) String($USERNAME) Tab() String($PASSWORD) Enter()"
zOS VTAM / TSO Login Macro Example
TSO login on zOS may require navigating through a VTAM application selection panel before reaching the userid prompt. The example below clears the current screen, types the TSO application name, presses Enter to open TSO, waits for the userid field, then enters credentials.
-loginmacro "Wait(InputField) Clear() String(TSO) Enter() Wait(InputField) String($USERNAME) Enter() Wait(InputField) String($PASSWORD) Enter()"
TSO in the example above) and the number of Wait/Enter steps to match your site-specific VTAM menu structure.TLS-Encrypted Connections
For hosts that require TLS (SSL) encryption, prepend L: to the hostname in the Process Arguments field:
-model 3279-2 L:$MACHINE $PORT -loginmacro "Wait(InputField) String($USERNAME) Tab() String($PASSWORD) Enter()"
The L: prefix instructs ws3270 to establish an SSL tunnel before initiating the TN3270 session. Hosts that support TELNET START-TLS negotiate the encryption automatically and do not require the L: prefix.
Command-Line Arguments Reference
The following table summarises the most useful ws3270 command-line options for secret-server process launcher configurations. For a full reference, see the ws3270 manual.
| Argument | Description |
|---|---|
-model <name>
|
Sets the 3270 terminal model. Common values: 3278-2 (mono, 80x24), 3279-2 (colour, 80x24), 3279-4 (colour, 80x43 – default). Use 3279-2 for most iSeries and zOS sessions. |
-charset <name>
|
Sets the EBCDIC host character set. Common values: bracket (US default), us-intl (US with euro), uk, german, french. Specify cp037 or cp500 for specific IBM code pages. |
-port <n>
|
Overrides the default TCP port (23). Useful when the host listens on a non-standard port. Can also be appended to the hostname as hostname:port. |
-loginmacro <actions>
|
Specifies a macro to execute immediately after connection. Used to automate credential entry. Multiple actions are separated by spaces and enclosed in quotes. |
-tn <name>
|
Overrides the terminal type string sent during telnet negotiation. The default is IBM-3279-4-E. Some hosts reject the -E suffix; prepend S: to the hostname to remove it instead. |
L:<hostname>
|
Hostname prefix (not a flag) that instructs ws3270 to open an SSL/TLS tunnel before the TN3270 session. Example: L:$MACHINE |
N:<hostname>
|
Hostname prefix that disables TN3270E negotiation and uses standard TN3270 instead. Use if the host does not support TN3270E. |
-trace
|
Enables data stream and event tracing to a file in the AppData directory. Useful during troubleshooting of macro timing or host negotiation issues. |
-tracefile <file>
|
Directs trace output to a specific file path instead of the default. Combine with -trace. |
-verifycert
|
Enforces SSL certificate validation for TLS connections. The connection is rejected if the certificate cannot be verified against a trusted CA. |
-cafile <file>
|
Specifies a PEM-format CA certificate file used to verify the host certificate when -verifycert is set. |
-proxy type:host[:port]
|
Routes the TN3270 connection through a proxy. Supported proxy types include: socks4, socks5, http. |
Macro Commands Reference
The following table describes the ws3270 script actions most commonly used within a -loginmacro sequence. Actions are case-insensitive and arguments are enclosed in parentheses.
| Action | Description |
|---|---|
Wait(InputField)
|
Pauses macro execution until the host unlocks the keyboard and a modifiable input field is available. This is the recommended way to synchronise before typing. |
Wait(Unlock)
|
Pauses until the host keyboard lock is released (AID response received). Less specific than Wait(InputField); use when the screen has no visible input field but you still need to wait for the host. |
Wait(Seconds, n)
|
Unconditional pause for n seconds. Use sparingly – prefer Wait(InputField) where possible. |
String("text")
|
Types the specified string into the current cursor position. Special characters such as newline (\n) and tab (\t) are interpreted. $VARIABLE tokens from secret-server are substituted before the macro runs. |
Tab()
|
Moves the cursor forward to the next unprotected (input) field on the screen, equivalent to pressing the Tab key on a 3270 terminal. |
BackTab()
|
Moves the cursor back to the previous input field. |
Enter()
|
Sends an AID (Attention IDentifier) Enter keystroke to the host and waits for the host to respond. |
Clear()
|
Sends the Clear AID to the host, clearing the current screen buffer. Commonly used to dismiss welcome or status screens before entering data. |
PF(n)
|
Sends the numbered Program Function key (F1–F24) to the host. For example, PF(3) sends F3, which typically maps to Exit or Return on many IBM applications. |
PA(n)
|
Sends Program Attention key 1, 2, or 3 (PA1–PA3). |
Home()
|
Moves the cursor to the home position (first unprotected field on the screen). |
MoveCursor(row, col)
|
Moves the cursor to an absolute screen position. Row and column are zero-based. Useful when Tab() navigation is unreliable due to host screen layout. |
Erase()
|
Erases from the current cursor position to the end of the current field. |
EraseEOF()
|
Erases from the cursor position to the end of the field (equivalent to the Erase EOF key on a 3270 keyboard). |
Disconnect()
|
Closes the TN3270 session. Rarely used in a login macro but useful at the end of an automated post-login workflow. |
Troubleshooting
Macro Does Not Enter Credentials
If the launcher starts but credentials are not typed into the host screen, verify the following points.
-
Confirm that
$USERNAMEand$PASSWORDare correctly mapped in the launcher field mapping (Step 3). Open the secret and check that both fields contain values. -
The
-loginmacrostring must be enclosed in double quotes in the Process Arguments field. Verify the argument string in the launcher definition. -
Add
Wait(InputField)before eachString()call to ensure the macro does not type before the host is ready. -
Enable tracing by appending
-traceto the Process Arguments and inspect the generated trace file for the sequence of actions.
ws3270.exe Not Found on Workstation
The Protocol Handler will report an error if it cannot locate ws3270.exe at the path specified in the launcher. Confirm that the file has been deployed to the exact path specified in the Process Name field, and that the path does not contain environment variables (use the fully resolved UNC or drive-letter path).
SSL / TLS Connection Failures
If ws3270 fails to connect when using the L: prefix, try the following.
-
Verify that the host certificate is valid and has not expired.
-
If the host uses a self-signed certificate, either distribute the CA to the workstation's trust store or add
-selfsignedokto the Process Arguments (not recommended for production). -
Confirm the TLS port (typically 992) is reachable from the workstation.
Character Set or Garbled Text
If the host screen displays garbled or incorrect characters, the -charset option may not match the host code page. Confirm the EBCDIC code page configured on the host and select the corresponding -charset value from the Command-Line Arguments Reference table. For non-US code pages, try specifying the code page number directly, for example -charset cp500 for EBCDIC 500.
References