coldfusion running commands in windows

How do I run batch commands from coldfusion?  Windows 2k server.

I'm trying to do FTP things that CFM can't seem to do with cfftp (like delte an entire directory w/out having to recusively loop).
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Tacobell777Connect With a Mentor Commented:
You could use <cfexecute> and use the windows ftp, i.e. command line ftp
cfftp tag lets u perform tasks on remote server using file transfer protocol(ftp).

You can use cfftp to cache connections for batch file transfers when uploading or downloading files.

Just a pseudo code for u

   <title>FTP Test</title>

<h1>FTP Test</h1>
<!--- Open ftp connection --->
<cfftp connection="Myftp"

<!--- Get the current directory name. --->
<cfftp connection=Myftp

<!--- output directory name --->
   The current directory is:  #cfftp.returnvalue#<p>

<!--- Get a listing of the directory. --->
<cfftp connection=Myftp
<!--- Close the connection.--->
<cfftp action="close" connection="Myftp">
<p>Did the connection close successfully?

<!--- output dirlist results --->
<p>FTP Directory Listing:</p>

<cftable query="dirlist" colheaders="yes" htmltable>
   <cfcol header="<B>Name</b>" TEXT="#name#">
   <cfcol header="<B>Path</b>" TEXT="#path#">
   <cfcol header="<B>URL</b>" TEXT="#url#">
   <cfcol header="<B>Length</b>" TEXT="#length#">
   <cfcol header="<B>LastModified</b>"
   <cfcol header="<B>IsDirectory</b>"

After you establish a connection with cfftp, you can reuse the connection to perform additional FTP operations .

If you're wanting to run a batch FTP process (as from the command line), save your script in a batch file (need help with this? it sounds like you may already know the ropes in this arena), then call the batch file from CF using <cfexecute>:

<cfexecute name="c:\batchfiles\ftpscript.bat" timeout="600" outputfile="c:\batchfiles\log.txt">

You have to remember to add the closing tag, even though there's nothing in the middle.

Hope this helps,

All Courses

From novice to tech pro — start learning today.