4 Replies Latest reply on Mar 26, 2009 2:47 PM by Newsgroup_User

    CFExecute with error return

    Coldfusion8.0
      :confused;
      Hi,

      Earlier CF4.5 uses CFX_SpawnExec (dll) which launches the VB exe but not working with CF8.0
      Installed CF8.0 in local machine and CFExecute successfully launched VB exe in synchronous, but it doesn't have any error return whether the execution is successful or unsuccessful.

      Working Code (without error return)
      <cfexecute name = "C:\ICS\Dll\Icsol.exe"
      arguments = "-inf 99068614"
      outputFile = ""
      timeout = "60">
      </cfexecute>

      After some more search found CFExecute has one more argument errorVariable which returns if any error occurs,
      but its working with a simple batch file but not while launching the VB exe.

      Working
      <cfexecute name = "C:\ICS\TestInforce.bat"
      arguments = ""
      errorVariable = "errVar"
      timeout = "60"
      variable="exResult">
      </cfexecute>

      Not working for VB exe
      <cfexecute name = "C:\ICS\Dll\Icsol.exe"
      arguments = "-inf 99068614"
      errorVariable = "errVar"
      timeout = "60"
      variable="exResult">
      </cfexecute>

      Could someone suggest to use CFExecute with an errorVariable parameter to execute a VB exe.

      thanks,
        • 1. Re: CFExecute with error return
          Coldfusion8.0 Level 1
          hi,
          Could some one help me on this issue

          thanks
          • 2. Re: CFExecute with error return
            Level 7
            Coldfusion8.0 wrote:
            >
            > Hi,
            >
            > Earlier CF4.5 uses CFX_SpawnExec (dll) which launches the VB exe but not
            > working with CF8.0
            > Installed CF8.0 in local machine and CFExecute successfully launched VB exe in
            > synchronous, but it doesn't have any error return whether the execution is
            > successful or unsuccessful.

            I think you'll need to use java.lang.Runtime.exec which returns a
            Process and has a method called exitValue().

            --
            Mack
            • 3. Re: CFExecute with error return
              Coldfusion8.0 Level 1
              Thanks Mack for your valuable suggestion,

              Can we rely on this java exec, because I tried it and sometimes its not consistent in executing VB exe (like process hangs up in the task manager and do nothing)
              things i have taken care:

              CF8.0 apllication service: checked "allow service to interact with desktop"
              CF8.0 administrator changed the Timeout value to 80 seconds (as our application vb exe will take around 60seconds to complete its job)
              Code:
              <cfset command = "C:\ICS\Dll\icsol.exe -inf 99068614">
              <cfset runTime = CreateObject("java","java.lang.Runtime").getRuntime()>
              <cfset process = runTime.exec(command)>
              <cfset result = process.waitFor()>
              <cfoutput> #result# </cfoutput>


              could you please let me know is there any other way to capture the return code,
              or do you suggest any 3rd party custom tags in the market that serves the purpose.



              Thanks,
              Shekar
              • 4. Re: CFExecute with error return
                Level 7
                Coldfusion8.0 wrote:
                > Thanks Mack for your valuable suggestion,
                >
                > Can we rely on this java exec, because I tried it and sometimes its not
                > consistent in executing VB exe (like process hangs up in the task manager and
                > do nothing)
                > things i have taken care:
                >
                > CF8.0 apllication service: checked "allow service to interact with desktop"
                > CF8.0 administrator changed the Timeout value to 80 seconds (as our
                > application vb exe will take around 60seconds to complete its job)
                > Code:
                > <cfset command = "C:\ICS\Dll\icsol.exe -inf 99068614">
                > <cfset runTime = CreateObject("java","java.lang.Runtime").getRuntime()>
                > <cfset process = runTime.exec(command)>
                > <cfset result = process.waitFor()>
                > <cfoutput> #result# </cfoutput>
                >
                >
                > could you please let me know is there any other way to capture the return code,
                > or do you suggest any 3rd party custom tags in the market that serves the
                > purpose.

                This is the only way that I know of getting the return code of a
                process. But if the VB program is not consistent then I think the
                problem is with the VB program (maybe it doesn't like to have more then
                one instance running ?).

                --
                Mack
                1 person found this helpful