1

I tried to run test.bat file using cfexecute. It shows timeout error after loding for sometime. The output file is blank. But when i double click the test.bat file it works fine. My code is this,

<cfexecute name="C:\Windows\System32\cmd.exe" arguments="/C C:\ColdFusion2018\cfusion\wwwroot\test.bat" timeout="60" outputfile="C:\ColdFusion2018\cfusion\wwwroot\log_output1.txt"></cfexecute>
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
  • 1
    This most likely is a permission issue. Try running the ColdFusion service using "Administrator" account instead of Local System account if you are in a local machine. Be cautious of using this production environment as it could be cause security issues. – rrk Dec 11 '19 at 10:42
  • 2
    @priyadharshan Add errorFile attribute in your cfexcute code. And update here if you have any error details. – Kannan.P Dec 11 '19 at 13:13
  • @Kannan. The errorFile is also blank.. – Priyadharshan Dec 12 '19 at 08:22
  • @Priyadharshan reduce the timeout attribute value from 60 to 0 or 1. I hope you can see the error details in whether outputFile or errorFile locations. – Kannan.P Dec 12 '19 at 12:15
  • @Kannan the issue is not with the timeout attribute. The commands need at least 30 seconds to return the output. I found out that, the .cmd file I'm calling through the batch file is not executed. I don't know why. I'm looking on it now. – Priyadharshan Dec 12 '19 at 12:55
  • @Priyadharshan, See I know your issue is not belongs to timeout. If you reduce that mean I hope you can get some error details. I've go through your issue in my local & get issue details in my local by reducing the time. – Kannan.P Dec 12 '19 at 13:53
  • I tried. The errorFile is blank. – Priyadharshan Dec 12 '19 at 13:56

3 Answers3

3

We recommend using CFX_EXEC (Windows) instead of the built-in CFExecute. When running BAT files, we've encountered many cases where we needed to run it under a separate Windows account that had privileges different than the CF Service. CFX_EXEC enabled us to specify the specific account whereas CFExecute doesn't have the option at all. We also use CFX_EXEC for performing IP/DNS look-ups as it's a lot faster than Java, honors TTL and doesn't cache the lookup results "forever".

James Moberg
  • 4,360
  • 1
  • 22
  • 21
  • It is not free. – Priyadharshan Dec 12 '19 at 09:07
  • 1
    Adobe ColdFusion 2018 isn't free either. For us, $30 was a very small investment to add account-specific privileges and TTL-honoring look-ups. (CF can't do either.) Imagine updating DNS, but being required to restart CF just to access the new server by hostname. There's a bunch of other features in CFX_EXEC that also aren't available in ColdFusion. (NOTE: The benefits of CFX_EXEC is one of the reasons we haven't migrated to Lucee as we haven't been able to register C++ CFX tags.) – James Moberg Dec 12 '19 at 16:21
2

Thanks for your response,

The batch file successfully executed after suppressing the 'Press any key to continue..'(pause) in the command line. It makes the cfexecute loading till timeout. That was the issue here.

1

If you want to run test.bat using cfexecute, test.bat should be the value of the name attribute, not the arguments attribute.

<cfexecute name="C:\ColdFusion2018\cfusion\wwwroot\test.bat" 
timeout="60" 
arguments ="whatever applies"
outputfile="C:\ColdFusion2018\cfusion\wwwroot\log_output1.txt">
</cfexecute>
Dan Bracuk
  • 20,699
  • 4
  • 26
  • 43
  • it also shows same blank `outputFile` and `time out` error.. I think it might be the permission issue in windows as @RRK stated. – Priyadharshan Dec 12 '19 at 09:05