Call a BATCH FILE from COLDFUSION page
Posted on 2006-05-03
Hi All you EXPERTS out there!
I have a cfm page that executes a simple query:
<cfquery datasource="#myDatasource#" name="getFiles">
Select source, destination, workgroup
Then I want to run a batch file inside a loop where I can pass the variables #source# and #destination# to the batch file. Inside the batch file, it will do an xcopy using the %1 and %2 variables I pass, then close, and return to the calling web page.
I need to call this batch file from inside the page. I am adding an exit at the end of the batch file, so it will close on completion of each copy, AND I want the loop to continue ONLY when the batch file closes and I also want it to collect the exitcode for use in tracking the success of the copy.
For the user of the page, I am building a table inside the loop to display the status:
***DO THE BATCH FILE STUFF****
<td>was copied to</td>
To summarize, is there a way to call a batch file from inside a web page... (cffile won't work - I need something else). Second, how can I track the execution of the bat file and continue the loop only when it returns an exitcode (no matter what the exitcode is for now), and how can I collect the exit code from the dos batch file, and show it as above?
Later I would like to add in error handling, but for now, I would be thrilled if the copy just worked and showed the table to the user. I am also toying with how to collect all the path and file names copied by the action.
Thanks a MILLION! (My head really hurts from banging it on this brick wall....)