Not yet rated

Problem

You have a program on your Windows web server that can only be run from command prompt but is needed in your ColdFusion web application.

Solution

You can use the ColdFusion function cfexecute to run the program.

Detailed explanation

Example of using cfexecute with GNUPG on Windows:

NOTE: double quotes used to pass spaces in paths, key, and user names but passphrase with GPG  can not be passed with quotes if not contained in passphrase

<cfexecute name="C:\WINDOWS\system32\cmd.exe" arguments="/c ""C:\inetpub\utils\gpg1.bat"",passphrase,""publickeytouse"",""C:\fullpath\somefile""" variable="result" timeout="2">
</cfexecute>

<cfoutput>#result#</cfoutput>

Windows .bat file gpg1.bat

@ECHO OFF
REM This batch file creates a ASCI PGP signed file encypted using 3DES
REM %1 = Senders' passphrase for private key to encrypt file
REM %2 = User Key of sender to sign and encrypt file
REM %3 = Public Key of recipient to sign file
REM %4 = File to encrypt and sign - include fullpath and extension

ECHO %1|gpg --homedir "C:\full_path_to_stored_keys\gnupg" -a --passphrase-fd 0 --cipher-algo 3des -sce --yes -u %2 -r %3 %4
CLS
dir /B %4.asc


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes