Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Running a Batch File From LISP

4 REPLIES 4
Reply
Message 1 of 5
btillman
2198 Views, 4 Replies

Running a Batch File From LISP

I have a batch program which I want to launch from a LISP program.

 

First this is an attempt at an automated process whereby user input is extremely restricted. Other than the first click of the mouse on the menu item to save a copy of the file to a very restricted folder, no other user input is allowed.

 

AutoCAD, like most commercial apps writes a temporary file and then renames it when you choose save or saveas. And due to the restrictions in this folder that will not work. Crazy, I know but it's the parameters I must work within.

The batch file I'm launching calls another batch program in it's execution and I'm wondering if that could be where control is lost. But the thing is I can type this at the command line in AutoCAD:


(startapp "//a_very_long/novell_server_path/my_folder/vlisp/mybatchfile.bat")

 

The whole process works great. The command window flashes briefly AutoCAD closes the active drawing window just like I want it to. And when I check that the dwg file has been copied to the restricted folder it's there and done. But when I place that same command within my LISP program or one like this:

(command "._STARTAPP" "CMD //a_very_long/novell_server_path/my_folder/vlisp/mybatchfile.bat")

or

(command "._STARTAPP" "CMD "\"//a_very_long/novell_server_path/my_folder/vlisp/mybatchfile.bat\"")

 
or just about anything else I try it fails to run. Perhaps I've been looking at this problem too long. I think I may move on to a VB.NET process to do this but I am really baffled why it will run from the command line but not within the program.

 

4 REPLIES 4
Message 2 of 5
cae
Enthusiast
in reply to: btillman

I always us e the SHELL command in LISP

 

      (command "SHELL" "//a_very_long/novell_server_path/my_folder/vlisp/mybatchfile.bat")

Message 3 of 5
johncavogt
in reply to: btillman

the doslib functions from McNeel include a shell that makes acad wait until the outside process is done - maybe that's what you need?

Message 4 of 5
martti.halminen
in reply to: btillman

That (startapp ...) call should work in an AutoLISP program, if it is the last thing you do.

 

Autolisp environment is separate for each drawing, so if your batch file closes the active AutoCAD window, the running Lisp program is lost.

 

--

Message 5 of 5
btillman
in reply to: martti.halminen

Thanks but the batch file doesn't shutdown anything. It only works on some text files and then makes a copy of the file which my lisp file created in the temporary location of C:\TEMP. I want to actually move the file instead of copying it but until I get the bugs worked out of this I will not take any chances that something might get erased before the copy is made. Call me paranoid at this point.

 

I have no less than three other LISP programs which do this and they all work fine. It's only this one LISP file which works with this restricted folder where the close command whacks AutoCAD upside the head. And at the time the close command is run the Active drawing is actually in the C:\TEMP folder so there should not be any problem with rights.

 

(command "._SAVEAS" "2004" "//path/folder/dwgname.dwg")
(command "._CLOSE") 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost