• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Execute .bat file using cfexecute tag...

New Here ,
Feb 16, 2009 Feb 16, 2009

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

7.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 16, 2009 Feb 16, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2009 Feb 16, 2009

Copy link to clipboard

Copied

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 😞

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 16, 2009 Feb 16, 2009

Copy link to clipboard

Copied

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/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 17, 2009 Feb 17, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2009 Feb 17, 2009

Copy link to clipboard

Copied

LATEST
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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation