Skip navigation
Currently Being Moderated

How can I get cfexecute to run a bat file? (It is not working for me)

Dec 8, 2011 12:40 PM

Tags: #batch #exe #captcha #execute #executable #cfexecute #bat

My server is running the following:

  • Windows Server 2003 R2 Enterprise Edition Service Pack 2
  • Coldfusion 9,0,0,251028 Standard Edition
  • Java Version 1.6.0_14
  • Coldfusion Application Service Log On set to Local System Account

 

 

I'm running some command line software to generate audio for a custom captcha form. I can't get this bat file to run with cfexecute. I can run the bat fine if I run it manually and it generates the .wav file but it will NOT run with cfexecute. I had tried running the exe with cfexecute while passing the arguments and all that outputed to the page was "[empty string]". I have read pretty much every forum post I can find searching through google and can't find the solution to my problem. Please someone help me out I'm wracking my brain over this.

 

 

Variables passed:

  • FileName=NFACZMU2-050031.wav
  • cap=NFACZMU2

 

<cfparam name="FileName" default="">

<cfparam name="Cap" default="">

 

<cfset newString = "">

 

<cfloop index="intChar" from="1" to="#Len( Cap )#" step="1">

          <cfset strChar = Mid( Cap, intChar, 1 ) />

          <cfset newString = newString & "#strChar#.....">

</cfloop>

 

<cfoutput>

<cfsavecontent variable="cmd_content">C:\TSC.exe /s "#newString#" C:\Inetpub\wwwroot\captcha\#FileName# Mary (for Telephone)</cfsavecontent>

</cfoutput>

 

<cfset cmd_filename = "#ListFirst(FileName, ".")#.cmd">

 

<cffile action="write" file="C:\Inetpub\wwwroot\captcha\#cmd_filename#" output="#cmd_content#">

 

<cfexecute name="C:\Inetpub\wwwroot\captcha\#cmd_filename#" outputFile="C:\testoutput.txt" timeout = "90"></cfexecute>

 

 

 

This is the content of testoutput.txt when the script is ran:

 

  C:\ColdFusion9\runtime\bin>C:\TSC.exe /s "N.....F.....A.....C.....Z.....M.....U.....2....." C:\Inetpub\wwwroot\captcha\NFACZMU2-050031.wav Mary (for Telephone)

 

What am I doing wrong?

 
Replies
  • Currently Being Moderated
    Dec 8, 2011 6:05 PM   in reply to Kastion2K

    I suggest starting slowly and working your way up.  Specifically, forget those variables for a minute.  Hard code the name of your batch file and try to run it with cfexecute.  Also, you mention passing the arguments, but see nothing in your code to indicate such.

     
    |
    Mark as:
  • Dave Watts
    747 posts
    Mar 11, 2003
    Currently Being Moderated
    Dec 9, 2011 12:49 AM   in reply to Kastion2K

    When I've done this before in the past, I've had better luck by running the batch file indirectly, as an argument to the command processor:

     

    c:\path\to\cmd.exe /c c:\path\to\myfile.cmd ...

     

    Dave Watts, CTO, Fig Leaf Software

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 9, 2011 8:21 AM   in reply to Kastion2K

    Try this to get more info.   Put acfabort in front of the cfexecute code.  Run your script - let it create the bat file and then stop before trying to execute it.  Then go into a DOS box on the same machine and execute the bat file manually, see what happens.  What does it give yoy for any errors, etc.

     

    Good luck

    reed

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points