• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Dec 08, 2011 Dec 08, 2011

Copy link to clipboard

Copied

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?

TOPICS
Advanced techniques

Views

4.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2011 Dec 08, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 09, 2011 Dec 09, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 09, 2011 Dec 09, 2011

Copy link to clipboard

Copied

I still can't get it to work that way. I changed my cfexecute to:

<cfexecute name="C:\windows\system32\cmd.exe" arguments="/c C:\Inetpub\wwwroot\captcha\#cmd_filename#" outputFile="C:\testoutput.txt" timeout = "90"></cfexecute>

And I changed my bat file to have:

<cfsavecontent variable="cmd_content">

cd\

TSC.exe /s "#newString#" C:\Inetpub\wwwroot\captcha\#FileName# Mary (for Telephone)

</cfsavecontent>

The output file is showing:

C:\ColdFusion9\runtime\bin>cd\

 

C:\>TSC.exe /s "3.....P.....4.....Z.....8.....U.....7.....X....." C:\Inetpub\wwwroot\captcha\3P4Z8U7X-105724.wav Mary (for Telephone)

I still can't get it to run the exe. I have watched the process list while running this and the exe doesn't show up. I tried cfexecute on the exe directly before trying the bat method, with hard coded arguments, and it still didn't work. I am so lost right now this makes no sense to me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 09, 2011 Dec 09, 2011

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation