Skip to main content
July 19, 2017
Question

cfexecute command fails to execute the vbscript.

  • July 19, 2017
  • 2 replies
  • 1618 views

I am trying to format an excel sheet using vbscript.  This script works fine when i execute it in the server.  But when i call this script from my CF component file. This script call does not show any error or success. 

Environment:  ColdFusion 11, Windows 7 , 64 bit Machine.

After checking some threads on office automation I found this .

We have to add the Desktop folder in the systemprofile and system32 folder to open file by Excel if you have Windows Service or IIS on Windows 7 x64 (dev machine) and Server 2008 x64.

So I added Desktop folder under these 2 directories -

C:\Windows\System32\config\systemprofile
C:\Windows\SysWOW64\config\systemprofile

I tried this as well.  Still no success.  Any suggestions??

VBScript Call from ColdFusion:

---------------------------------------

<cfexecute name = "C:\Windows\System32\cscript.exe" arguments  = "//Nologo #GV_SCRIPTPATH#" timeout="50000"  variable = "savedOutput"></cfexecute>

<cflog text="#savedOutput#">

    This topic has been closed for replies.

    2 replies

    James Moberg
    Inspiring
    July 19, 2017

    Which user account is ColdFusion running under?  Does it have the necessary rights to run the script?

    As a work around, there's a commercial third-party C++ CFX tag called CFX_EXEC that will enable you to run any script using any user/pass/domain and/or working directory.  I've used it in the past when I needed elevated (or simply different) permissions in order to access something.

    July 19, 2017

    Currently my ColdFusion service is running under my user account.  My account has access to run the vbscript. 

    Let me try with CFX_EXEC and see if it works.  I will update you.  Thanks for looking into it.

    Carl Von Stetten
    Legend
    July 19, 2017

    I can't say why the VBScript command doesn't work, but have you considered using the ColdFusion built-in spreadsheet tools or Apache POI to do your formatting?  Is there something it can't do that VBScript can?

    July 19, 2017

    My requirement is to generate an excel sheet with dynamic columns and rows. CF Spreadsheet in built functions does not have some options like vertical column orientation.  VBscript i have created does that for me quickly.  It is very effective and faster.