About cfExec
cfExec wraps 85+ command-line tools with ColdFusion CFCs. Instead of hand-building argument strings for CFExecute every time, you get typed methods, version detection, and consistent result structs. Each tool has its own CFC that extends a common base.
Why use command-line tools within ColdFusion?
ColdFusion has built-in functions for a lot of things. Sometimes they're not enough.
Performance
We had an Excel file with 88,000 rows and two columns. CFSpreadsheet locked up trying to process it. The same operation on the command line took less than two seconds. (We also prefer using the 3rd-party Spreadsheet CFML library.)
CFImage added 2 to 8 seconds per image for resizing. We switched to GraphicsMagick and it was so fast the team thought it wasn't working.
An S3 file transfer through ColdFusion's built-in s3:\\ protocol support took 110 seconds. S3Express did the same transfer in 16.
Quality and features
Dedicated CLI tools tend to solve their specific problem better than a general-purpose runtime can. They support more options, handle more edge cases, and get updated on their own schedule rather than waiting for the next CF release.
File support
We ran into cases where isPDFFile returned true but cfPDF threw an error on the same file. Photos from an iPhone 4 would register as invalid JPGs using ColdFusion's image functions but worked flawlessly when transformed using ImageMagick and GraphicsMagick.
Java limitations
Heap exceeded. GC overhead limit exceeded. DNS caching that's either all or nothing. Silent failures where Java swallows exceptions and returns empty results. When you hit these walls, an external process sidesteps the JVM entirely.
Remote API problems
SSL certificate changes, round-robin DNS with short TTLs, domain name expirations, beta-to-paid plan transitions, rate limiting. These are things outside your control that break without warning. A local CLI tool with no network dependency won't wake you up at 3 AM because someone else's certificate expired.
Versioning
You can run different versions of the same tool side by side. Keep a deprecated version around while you test a beta. Use a feature flag to switch between them. Try doing that with a built-in function.
BAT file tips
- Use
set PATH=%PATH%;D:\YourDirin a BAT file to temporarily add a directory to the path. Useful when the EXE depends on DLLs in a resource folder. cd /d "%~dp0"sets the working directory to wherever the BAT file lives. Saves you from hardcoding paths.- Pipe secrets through stdin or set them as environment variables in the script. Don't hardcode credentials in argument strings.
- BAT files can accept arguments (
%1,%2, etc.) and become reusable wrappers. - Windows cmd.exe does not support UTF-8. It uses single-byte OEM encodings like cp437 or cp775 depending on regional settings. If your output looks garbled, that's probably why.
CFML tips
- Add feature flags so you can toggle between the command-line tool and ColdFusion's built-in function. Makes it easy to compare results or fall back if the EXE is missing.
- Use the documented case for arguments. Some tools are case-sensitive, and getting it wrong produces confusing errors or silent failures.
- Build your arguments as an array in the documented order, then join them into a string. Order matters for many CLI tools.
- Write a CFC wrapper. That's what this project does, and it saves you from re-learning the argument syntax every time.
- Wrap every CFExecute call with
cftry/cfcatchandcffinally. Clean up temp files and check exit codes. - For heavy workloads, use a queue. Generate BAT files and watch the directory with a scheduled task, or build a lightweight API server with something like Taffy REST Web Service Framework.
Built by James Moberg, CTO of SunStar Media. Originally presented as "CF_PB&J: Enhancing ColdFusion with Command Line Magic" at the ColdFusion Summit 2025 in Las Vegas, NV and based on the "CFFrankenstein: Choosing to use EXEs instead of CFML BIFs"" blog post at myCFML.