Skip to main content
Participant
July 27, 2021
Question

cfexecute to run cscript.exe

  • July 27, 2021
  • 3 replies
  • 917 views

Hi,

I have batch & js file which convert to word to pdf using cscript.exe.

when I execute batch file directly it convert the files. But if call through browser using below cfm file  I 

my coldfusion page never end the execution and no output files created.

<cfexecute name="C:\Windows\System32\cmd.exe" arguments="/c #expandpath('./Word2PDF.bat')#" timeout="2000"></cfexecute>

 

    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    Community Expert
    July 27, 2021

    See my recent solution to a similar problem: generating PDF from Word using a batch file, cscript.exe and so on

    https://community.adobe.com/t5/coldfusion/cfexecute-problem/td-p/12145050 

    Default1Author
    Participant
    July 28, 2021

    Try the method throw Timeout period expired error but it take very long time.

    BKBK
    Community Expert
    Community Expert
    July 28, 2021
    quote

    Try the method throw Timeout period expired error 


    By @Default1

    Which method did you try?

    What happens when you try the following code?

     

    <cfexecute name="#expandpath('./Word2PDF.bat')#" timeout="60"></cfexecute> 

     

     

     

    but it take very long time.

    You have set timeout to 2000 seconds, which is a relatively long time for file conversions.

     

    Charlie Arehart
    Community Expert
    Community Expert
    July 27, 2021

    I have a few things to consider.

     

    First, I'd recommend you do a cfoutput/cfdump of your expandpath result, and then make sure that's valid (that if you drop the result into the command line or windows file explorer--on the server, the bat file tries to run.)

     

    Second, consider also that it will run as the user running cf, which may respond differently compared to you doing the above, when logged into ther server yourself.

     

    As for it hanging, if you had a tool setup to monitor cf, you may find what it's hung on. There is the cf pmt for cf2018 and up, or fusionreactor or other jvm tools that can be configured to work for any cf version.

     

    And consultants like Dave and I (and others) can help get such monitoring set up, where that would be helpful.

     

    Let us know if the first couple of tips I offered help, or if you learn more otherwise. 

    /Charlie (troubleshooter, carehart. org)
    Default1Author
    Participant
    July 28, 2021

    Hi,

    As mention other replies I try to output path no problem. I add this cfm page in schedule task see whether it work but same so output and throw Timeout Period expired if take more than half hour to show the error.

     

    Charlie Arehart
    Community Expert
    Community Expert
    July 28, 2021

    I see no other replies from you indicating that. Where do you report that result to us? And I listed still more for you to consider. 

    /Charlie (troubleshooter, carehart. org)
    Community Expert
    July 27, 2021

    Can you break out your CScript code into a separate file, then invoke cscript.exe as the program you're trying to run? It's difficult to have CFEXECUTE run one program which then invokes another one, because of path stuff & permissions and so on.

     

    Dave Watts, Eidolon LLC

    Dave Watts, Eidolon LLC
    Default1Author
    Participant
    July 28, 2021

    Hi ,

          I split code and directly all csript.exe to run js file,but no use. Still it took long time execution without output.

    In my server task maganer I can view cscript.exe and winword.exe are trigger after I call my cfm page in user browser.