I got it working.
The problem is that Railo needs backslashes escaped, so \ becomes \\
This modified version of your original example works on my
installation:
<cfparam name="success" default=1>
<cftry>
<cfexecute name="C:\\myApp\\backupFile.bat" variable="backupoutput"/>
<cfcatch type="any"><cfset success = 0></cfcatch>
</cftry>
success = <cfoutput>#success#</cfoutput><br>
backupoutput = <cfoutput>#backupoutput#</cfoutput><br>
In my version of backupFile.bat, the contents are:
@echo off
Echo Backup Complete
Command Line tools have two main output streams, Standard Output
(stdout) and Error Output (errout).
After looking at Ben Forta's site, he states that cfexecute only
captures stdout, which is the case in Railo as well.
But if you have errout, it can be redirected to stdout within a batch
file, here is an example of a modified backupFile.bat which redirects
errout (2) to stdout (1):
@echo off
echo Backup Complete
echo Error Out 2>&1
That works in Railo too, you will see both lines echo out.
There seems to be an issue with Railo with spaces in the cfexecute
arguments attribute, here is a link:
http://www.photoswarm.com/blog/?p=204
I think it is only important if spaces exist in the path of a file
name in the argument.
"/c c:\\myfile.txt" seems to be ok, but "/c c:\\my file.txt" is not
ok.
That can be fixed if you call cfexecute like this:
<cfexecute
name="C:\\WINDOWS\\system32\\cmd.exe"
arguments="/c 'C:\\myApp\\backup File.bat'"
variable="myoutput"
timeout="15"/>
there you see that around the c:\\myApp\\backup File.bat there are
single quotes in there, that fixes the space problem in the file name.
Hope that helps.
Cheers,