5 Replies Latest reply on Sep 19, 2013 7:54 AM by tribule

    Run/Start .Exe file in ColdFusion

    Tommy Armani

      Hi guys,

       

      am trying to open up a .exe file like notepad or whatever windows program with using <cfexecute> but seems it doesn't work at all. I'm able to write the command in cmd and run the exe file but when i put the command in cfexecute so i get nothing.

       

       

      here is the command i would like to run:

       

      "C:\Program Files (x86)\Vc\vc.exe" -e "\Crystal\BF_Faktura_D.rpt"

       

      altso, run/start a simple .exe windows program. I think there is something about security access from CF server or something like that.

       

      ANY HELP?

        • 1. Re: Run/Start .Exe file in ColdFusion
          tribule Level 2

          Hi,

           

          Here's how I do this:

           

          <cfexecute name="C:\Windows\System32\cmd.exe" arguments="/C C:\batchfile.bat" timeout="999"></cfexecute>

           

          where batchfile.bat contains the commands to run. No other changes were made to the CF server to allow this to work.

           

          Regards,

          Mark

          • 2. Re: Run/Start .Exe file in ColdFusion
            Tommy Armani Level 1

            this is what i have in my .bat/.cmd file:

             

            "C:\Program Files (x86)\Vc\vc.exe" -e "\Crystal\BF_Faktura_D.rpt"


            And i would like to remove that batch file totaly and run the command directly from CF to be able to make a HTML form and put some inputs through that form.

            here you can see what i really do in bat file:

             

            echo parameters:

            echo      fakturagruppe  : %1

            echo      fakturanr(fom) : %2

            echo      fakturanr(tom) : %3

             

            "C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe" -e "\BF_Faktura_D.rpt" "Parm1:%2>>>%3>>>3" "Parm2:false" "Parm3:%1" "Parm4:false"

            "Export_File:\\bf-visma02\vismadata\vbdoc\F0001\Fakturakopi\IC{BF_Faktura_S.InvoNo}.pdf" "Export_Format:Adobe Acrobat (pdf)"

             

             

             

            I would like to open Visual cut.exe through CF to be able to make thos parameters in an HTML form instead of inputs from .bat file as you see!

            • 3. Re: Run/Start .Exe file in ColdFusion
              tribule Level 2

              You can't remove the batch file totally because you have to run the DOS commands contained within it. Also, ColdFusion is not run like a DOS batch file; calling a .cfm template is not like taking arguments from a command line.

               

              I think what you mean is that you want to pass parameters from a form to the batch file, in which case all you have to do is substitute in the ColdFusion parameter. So you need two pages, one with the HTML form, and one with the CF page with the <cfexecute> in it.

               

              For example you could do this:

               

              file 1: file1.cfm

               

              <form method="post" action="file2.cfm">

              Param 1 <input type="text" name="param1" value="C:\batchfile.bat" />

              </form>

               

              file 2: file2.cfm

               

              <cfexecute name="C:\Windows\System32\cmd.exe" arguments="/C #Form.param1#" timeout="999"></cfexecute>

               

              which would substitute "C:\batchfile.bat" into the <cfexecute> tag, to allow you to run different batch files. This is just a simple example to show you how to substitute a value.

               

              Btw, CF can create PDFs - if you can use CF throughout, that would be a better solution than calling a batch file.

              1 person found this helpful
              • 4. Re: Run/Start .Exe file in ColdFusion
                Tommy Armani Level 1

                Ok that was one step forward. but still having some other issues...

                 

                Now i see that the program which has commanded in bat file is running in Task manager but it does not get oppened as a windows interface. (may not be a problem, i don't know!)

                 

                Another thing is that i want to get those %1 %2 %3 parameters through a HTML form and not from the batch file. I mean get those parameters/variables/inputs from a HTML form and put it in the batch file. Do you think it's possible?

                 

                HTML form

                 

                input1 = %1

                input2 = %2

                input3 = %3

                 

                 

                and then put them here: (.bat file)

                 

                "C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe" -e "\BF_Faktura_D.rpt" "Parm1:%2>>>%3" "Parm2:false" "Parm3:%1" "Parm4:false"

                "Export_File:\Invoice\IC{BF_Fakt ura_S.InvoNo}.pdf" "Export_Format:Adobe Acrobat (pdf)"

                • 5. Re: Run/Start .Exe file in ColdFusion
                  tribule Level 2

                  The % variables represent command line parameters, so no, these cannot be passed to ColdFusion, as far as I know, because a .cfm template is not run from the command line. You will have to create separate batch files for each combination, and then call them.