Skip to main content
Jul 19, 2017 1:21 PM UTC
Question

cfexecute command fails to execute the vbscript.

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 is closed to new replies. Start a new post to keep the conversation going.

    6 replies

    James Moberg
    Inspiring
    Jul 19, 2017 5:59 PM UTC

    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.

    Translate
    Jul 19, 2017 6:15 PM UTC

    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.

    Translate
    Carl Von Stetten
    Legend
    Jul 19, 2017 4:05 PM UTC

    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?

    Translate
    Jul 19, 2017 6:10 PM UTC

    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.

    Translate