5 Replies Latest reply on Feb 17, 2009 5:47 AM by Dan Bracuk

    Execute .bat file using cfexecute tag...

    Manju82
      Hello,

      I am trying to execute a batch file using cfexecute tag. This batch file needs 1 command line arguement, which I am passing using arguments Text attribute.

      When I run my batch file directly from command prompt, it works perfectly. but while using cfexecute, it doesn't seem to do anything.

      Note:- I am trying to encrypt a txt file using GPG algorithm in the batch file.

      Thanks in advance!
      Manju
        • 1. Re: Execute .bat file using cfexecute tag...
          Level 7
          Manju82 wrote:
          > Hello,
          >
          > I am trying to execute a batch file using cfexecute tag. This batch file needs
          > 1 command line arguement, which I am passing using arguments Text
          > attribute.
          >
          > When I run my batch file directly from command prompt, it works perfectly. but
          > while using cfexecute, it doesn't seem to do anything.

          You'll need to run cmd.exe with the bat file as your first argument and
          using the /c switch on cmd.exe if I remember correctly (the command like
          would look something like this: cmd.exe /c your_bat_file.bat your other
          arguments).

          --
          Mack
          • 2. Re: Execute .bat file using cfexecute tag...
            Manju82 Level 1
            thanks for the reply mack!

            I tried openeing only cmd.exe i.e. I tried the below
            <cfexecute name = "cmd.exe" timeout = "20">
            </cfexecute>
            But it just times out :(
            Also there is no process running in the backgroud, I checked it in the task manager.

            I dont know, something is wrong :(
            • 3. Re: Execute .bat file using cfexecute tag...
              Level 7
              you do not need to call cmd.exe to execute a .bat file.
              you must, though, provide a full absolute filepath to the .bat file,
              even if it is in the same dir as the calling page.

              also, if you are calling any other executables inside your .bat file,
              you must call them with a full filepath to the executable.

              Azadi Saryev
              Sabai-dee.com
              http://www.sabai-dee.com/
              • 4. Re: Execute .bat file using cfexecute tag...
                Hagster Level 1
                Hello,
                you have probally worked this out but if any of this helps :)

                I run an application that needs to print via dos command, so my cfm page makes a batch file writes some arguments to it then calls it with a cmd. the code is below if any of it helps im glad.

                (creates name for my bat file)
                <cfset BFname = '#namevariable#' & '.bat'>

                (sets up the text I need in the bat file)
                <cfset content = 'copy "c:\inetpub\wwwroot\mct\picklist.txt" \\MyPrintServer\ThePrinter'>

                (writes the bat file with the text in the content var)
                <cffile action="write" file="c:\inetpub\wwwroot\mct\#BFname#" output="#content#">

                (calls cmd to run the bat file)
                <cfexecute name="c:\windows\system32\cmd.exe" arguments="/c c:\inetpub\wwwroot\mct\#BFname#" outputfile="c:\inetpub\wwwroot\mct\log_output.txt" timeout="1"></cfexecute>

                Regards Guy
                • 5. Re: Execute .bat file using cfexecute tag...
                  Dan Bracuk Level 5
                  I do it like this:

                  some code to create a file,

                  <cfexecute arguments="#session.filename#"
                  name="d:\dw\Guest Sites\kc_infogram\printme.bat">
                  </cfexecute>