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

cfexecute to run cscript.exe

New Here ,
Jul 26, 2021 Jul 26, 2021

Copy link to clipboard

Copied

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>

 

Views

572

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 ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

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

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

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.

 

 

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 ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

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)

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

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.

 

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

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)

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

I do see now that in a reply to Dave, you indicate that you saw winword (and cscript) in task manager, once you run the cfm page.

 

Ok, then by that we could infer that those were triggered by cf, in which case it confirms that the path was OK. Still, it begs two more questions.

 

First, BEFORE you run such a test, have you tried  confirming that there is NO listed winword.exe in task mgr? Doing that would ensure that the one you see after running the cf page is indeed from cf.

 

Second, what is the user listed in task mgr, shown running the winword process? That goes back to my first comment above. I'd suspect that the user running it from cf would be quite different from when you run it, and that may be significant. 

 

Finally, it could be that running winword (specifically) from cf may be a particular challenge. As such, it could be worth considering its various command line args for launching it. I see there's one, /x, that seems to be important for some such automation tasks. You may need to do that or something else like it (like /q), when launching winword from something like cf, which has no terminal attached.

 

Just sharing ideas. You've got 3 of us on it. Hopefully we or others will help you get to a solution. 


/Charlie (troubleshooter, carehart.org)

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 ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

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 

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

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

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

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.

 

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 ,
Aug 03, 2021 Aug 03, 2021

Copy link to clipboard

Copied

@Default1 , is your word-to-pdf conversion working now?

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 ,
Aug 03, 2021 Aug 03, 2021

Copy link to clipboard

Copied

Hi BKBK,

 

Still not working. I try to  use coldfusion schedule task option  to convert but not working.

 

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 ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

LATEST

Sad to hear. I would suggest that you first get the CFM page to work, before running it as a scheduled task.

 

Could you share with us the code of the CFM page?

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