The only solution that I have found to be able to "batch" in lisp is a little drawn out. I will try to explain it as simply as I can.
The solutions uses the registry and the acaddoc.lsp.
The acaddoc.lsp loads the "batch.lsp" (this is the executing lisp). In this lisp there is some code that checks the registry for a flag (and a few other things)
;;From the acaddoc.lsp;;
;; Appload the Batch program
(load "Batch.lsp")
;;From the Batch.lsp
(setq BatchMasterKey "HKEY_CURRENT_USER\\Software\\Batch")
(if (= (vl-registry-read BatchMasterKey "Run") "T")
;; Run the batch if it is not nil
(load (vl-registry-read BatchMasterKey "Batch") "Unable to load the specified Batch!")
)
When the executing lisp is run, it creates a document reactor in the current drawing which checks for that drawing to become current again. Then it sets the registry flags that are read by the opening lines of the batch.lsp. Then the drawings are opened. (there is a little more detail here that I am skipping). One of the registry flags is a lisp file (this is the "batch process"). This is loaded into the (s:startup) so that it will execute once the drawing is fully opened.
Since the flag has been set, when the drawings begin to open the "batch process" is executed automatically. Once the drawing is fully opened, the "batch process" runs. (this "batch process" closes the drawing when it is complete). Once all of the drawings have been "processed" and the current drawing takes focus, the reactor resets the flags in the registry and deletes the reactor.
Example of a "batch process":
;; Add the start up
(defun S::STARTUP (/)
;;; ------------ ECHO TO THE COMMAND LINE
(princ "\n Begining Batch Process \n")
;; Set the dbmod
(acad-push-dbmod)
;; Run some shtuff
(alert "test")
;; Reset the dbmod
(acad-pop-dbmod)
;; Close the drawing
(vl-cmdf "CLOSE")
)
[\code]
This seems to work for me with out any issue. I tried using scripts to batch process but if it fails, it stops. Since I am using lisp I can capture and report errors with out stopping. Also since I am using lisp and a document reactor I can set other flags to execute after the batch has been completed. I am able to execute .lsp, exe, .vbs, open documents, open explorer, send email, endless possibilities.