Command line parameters
You can use command line options to bypass ViewerFX for Crystal Reports default behavior — open a specific report, run unattended exports and emails, override database connections, and pass report parameters. All command line options are optional.
How to Use Command Options
Section titled “How to Use Command Options”On Windows, right-click the ViewerFX for Crystal Reports shortcut icon and choose Properties. In the Target input box of the Shortcut tab, put the command option after the quote, for example c:\program files\origin software\viewerfx\viewerfx.exe c:\my reports\reportname.rpt userid=sa password=test. The exact path to viewerfx.exe depends on where you installed ViewerFX; the shortcut’s Target already contains it.
Keys are case-insensitive. Values are passed through verbatim, so wrap any value that contains spaces or special characters in double quotes.
Note: Command-line integration requires a Standard or Site license. In Free Mode or with an expired license it is disabled — a headless (Export= / Email=) run in that state exits with code 8.
Identifying the Report
Section titled “Identifying the Report”| Option | Result | Example |
|---|---|---|
<path> (positional) | Open the .rpt file at this path. If only one argument is supplied and it resolves to an existing file, it is treated as the report. | viewerfx.exe "C:\Reports\Sales.rpt" |
Report= | Same as the positional <path>. Use this form when other switches are also present. | Report=C:\Reports\Sales.rpt |
R{id} | Open favorite #id from the local Favorites store. The six-digit zero-padded form is fine too (R000067). The Command Line field in Organize Favorites copies the exact string. | viewerfx.exe R67 |
Headless Export
Section titled “Headless Export”| Option | Result | Example |
|---|---|---|
Export= | Write the report to this path and exit. Triggers headless mode (no shell, no splash). Combine with Format= to pick a format. | Export=C:\out\daily.pdf |
Format= | Export format integer. Defaults to 1 (PDF). See the Format Integers table below. | Format=2 |
Headless Email
Section titled “Headless Email”| Option | Result | Example |
|---|---|---|
Email= | Recipient address(es). Multiple recipients are separated by ; or ,. Triggers headless mode. The attachment is named after the report (or Name=) and uses the Format= extension. | Email=user@example.com |
Subject= | Email subject line. | Subject=Daily Sales Report |
Body= | Plain-text email body. | Body=See attached. |
Format= | Attachment format integer (same enum as Export=). Defaults to 1 (PDF). | Format=2 |
Name= | Attachment filename without extension. Empty or absent falls back to the report’s base name. The extension comes from Format=. | Name=December-Sales |
Profile= | Outlook profile name for MAPI.Logon. Without it, the running Outlook’s default profile is used. Modern Outlook may ignore this and prompt anyway depending on profile config. Outlook transport. | Profile=Service Account |
ProfilePassword= | Password for the Outlook profile. Paired with Profile=. | ProfilePassword=secret |
SmtpServer= | Name of a saved SMTP server (matches the SMTPServer.Name column managed under interactive Send Email → SMTP Bookmarks). When set, sends through the SMTP transport instead of Outlook; the host, port, sender, and encrypted password are read from the saved row — no plaintext credentials on the command line. Wins over Profile= when both are present. | SmtpServer=Origin AWS SES |
Database Connection Overrides
Section titled “Database Connection Overrides”Database overrides are applied at load time. There are two forms — emit only one. The Command Line Builder generates DataSources= for every report; the single-block switches are still accepted for back-compat with existing customer scripts.
Single-block (legacy, applies to every table).
| Option | Result | Example |
|---|---|---|
ServerName= | Database server name or ODBC DSN. | ServerName=127.0.0.1 |
DatabaseName= | Database (catalog) name. | DatabaseName=MyDB |
UserID= | Login user name. | UserID=sa |
Password= | Login password. Pass the value plain — quote with "…" if it contains spaces or &. | Password=test |
Trusted= | Use Windows integrated security instead of UserID= / Password=. Values: 1, true, yes (case-insensitive). | Trusted=True |
Per-table inline (recommended).
| Option | Result | Example |
|---|---|---|
DataSources= | Inline JSON payload of per-table credentials (one row per Crystal table across the main report and every subreport). Passwords inside the JSON are TripleDES-encrypted with the same key chain ViewerFX uses for stored SMTP passwords — no plaintext credentials on the command line. Takes precedence over the single-block switches above when both are present. Generated by the Command Line Builder; hand-authoring is supported but not encouraged. | DataSources="{""version"":1,""product"":""ViewerFX.Datasources"",""tables"":[…]}" |
Report Behavior
Section titled “Report Behavior”| Option | Result | Example |
|---|---|---|
CrystalPrompt= | When false (0, false, no), unfilled parameters won’t pop Crystal’s native prompt dialog — important for headless runs that would otherwise block. Defaults to Crystal’s own setting. | CrystalPrompt=0 |
@ParameterName= | Pass a value for a named Crystal parameter. Repeat the switch for each parameter. If the parameter name itself starts with @ (rare), double up the @. | @StartDate=1/1/2026@EndDate=12/31/2026 |
Startup Behavior
Section titled “Startup Behavior”| Option | Result | Example |
|---|---|---|
SuppressLogo= | Suppress the startup splash. Values: 1, true, yes. | SuppressLogo=1 |
Format Integers
Section titled “Format Integers”Used by Format= for both Export= and Email=.
| Value | Format | Extension |
|---|---|---|
| 1 | .pdf | |
| 2 | Excel 97-2003 | .xls |
| 3 | Excel 97-2003 Data-Only | .xls |
| 4 | Word 97-2003 | .doc |
| 5 | Word 97-2003 Editable | .rtf |
| 6 | Rich Text Format | .rtf |
| 7 | XML | .xml |
| 8 | Plain text | .txt |
| 9 | CSV | .csv |
| 10 | Tab-separated text | .txt |
| 11 | Crystal Reports | .rpt |
| 12 | HTML 3.2 | .htm |
| 13 | HTML 4.0 | .htm |
ViewStyle= is ignored. The switch from the legacy WinForms build is silently ignored. Only the Fluent ribbon shell exists; there is no longer a classic UI to switch into.
Headless mode is triggered by the presence of either Export= or Email=. The WPF shell never paints, stdout gets a one-line success summary, stderr gets a diagnostic on failure, and the exit code is non-zero on failure:
| Exit code | Meaning |
|---|---|
| 1 | CLR / Crystal engine error |
| 2 | No report specified |
| 3 | Report path does not exist |
| 4 | Email send failed |
| 5 | Favorite lookup failed |
| 6 | Operation denied by administrative policy (the Export / Email action or the requested Format is turned off in Customize, typically deployed via an admin .vfx overlay) |
| 7 | DataSources= payload could not be parsed or applied |
| 8 | Command-line integration is not licensed (Free Mode or expired license) |
Concurrent runs. The single-instance lock is skipped for headless invocations, so an Export= or Email= run can launch alongside an open interactive shell or alongside other headless runs. A second interactive instance still exits silently.
Connection precedence at headless runtime: DataSources= → legacy single-block (ServerName= etc.) → embedded credentials. The first one with content wins.
Email transport precedence at runtime: SmtpServer= → Profile= (Outlook MAPI) → running Outlook’s default profile.
cmd.exe caveat. Because ViewerFX.exe is a Windows-subsystem app, cmd does not wait for it. Use start /wait viewerfx.exe … or invoke from PowerShell to block on the result and pick up %ERRORLEVEL%.
Examples
Section titled “Examples”Full headless email with parameters and a connection override.
viewerfx.exe "C:\Reports\Sales.rpt" ^ "Email=ops@example.com;manager@example.com" ^ "Subject=December Sales" ^ "Body=See attached." ^ "Format=1" ^ "Name=December-Sales" ^ "SmtpServer=Origin AWS SES" ^ "ServerName=PRODDB" ^ "DatabaseName=Sales" ^ "Trusted=True" ^ "CrystalPrompt=0" ^ "@StartDate=12/1/2026" ^ "@EndDate=12/31/2026" ^ "SuppressLogo=1"The same run with per-table credentials via DataSources=. The Builder generates this — copy from the Command Line Preview rather than hand-authoring:
viewerfx.exe "C:\Reports\Sales.rpt" ^ "Export=C:\out\daily.pdf" ^ "Format=1" ^ "DataSources={""version"":1,""product"":""ViewerFX.Datasources"",""tables"":[{""reportName"":"""",""tableName"":""Customer"",""server"":""PRODDB"",""database"":""Sales"",""userId"":""rpt_reader"",""password"":""...base64..."",""trusted"":false}]}" ^ "CrystalPrompt=0" ^ "SuppressLogo=1"