This content has been marked as final. Show 5 replies
> 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
> 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
thanks for the reply mack!
I tried openeing only cmd.exe i.e. I tried the below
<cfexecute name = "cmd.exe" timeout = "20">
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 :(
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.
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>
I do it like this:
some code to create a file,