Visual LISP, AutoLISP and General Customization

Reply
Active Contributor
Posts: 42
Registered: ‎07-25-2012
Message 1 of 5 (534 Views)

Running a Batch File From LISP

534 Views, 4 Replies
08-15-2012 05:01 AM

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.

 

Active Contributor cae
Active Contributor
Posts: 43
Registered: ‎11-09-2009
Message 2 of 5 (529 Views)

Re: Running a Batch File From LISP

08-15-2012 05:31 AM 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")

Member
Posts: 4
Registered: ‎05-11-2012
Message 3 of 5 (510 Views)

Re: Running a Batch File From LISP

08-15-2012 03:28 PM 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?

Valued Mentor
Posts: 304
Registered: ‎12-31-2009
Message 4 of 5 (498 Views)

Re: Running a Batch File From LISP

08-16-2012 02:10 AM 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.

 

--

Active Contributor
Posts: 42
Registered: ‎07-25-2012
Message 5 of 5 (486 Views)

Re: Running a Batch File From LISP

08-16-2012 08:07 AM 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") 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community