Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!nx02.iad01.newshosting.com!newshosting.com!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail From: A Retey Newsgroups: comp.soft-sys.math.mathematica Subject: Re: How to run ".nb" file always in dos command line Date: Wed, 14 Dec 2011 11:10:37 +0000 (UTC) Organization: Steven M. Christensen and Associates, Inc and MathTensor, Inc. Sender: steve@smc.vnet.net Approved: Steven M. Christensen , Moderator Message-ID: References: Lines: 40 NNTP-Posting-Date: 14 Dec 2011 10:15:20 GMT NNTP-Posting-Host: cb295ad7.news.twtelecom.net X-Trace: DXC=K^f?D>idSM84c1ZETcjjP3C_A=>8kQj6==_1NR_H?JP=;T8l36j_JW?EFiONJ7[Go6PPU\P:F:Qj8 X-Complaints-To: abuse@twtelecom.net Xref: x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:7207 Hi, > You can evaluate your notebook from the command line with a > procedure such as this. > > Assuming your working directory is C:\temp\plot demo > > create a text file C:\temp\plot demo\runplot.m containing this: > > > Needs["JLink`"]; > $FrontEndLaunchCommand = "Mathematica.exe"; > UseFrontEnd[ > selected = Select[Notebooks[], > CurrentValue[#, NotebookFileName] === "1.nb"&]; > If[selected != {}, > targetnotebook = First@selected; > SelectionMove[targetnotebook, All, Notebook]; > SelectionEvaluate[targetnotebook]; > ]; > Exit[]]; While I think the above should work, for version 8 it probably can be achieved somewhat simpler with something along these lines: UsingFrontEnd[ NotebookEvaluate[NotebookOpen["full/path/to/file.nb"]] ] UsingFrontEnd was new in version 7 and seems to replace UseFrontEnd from the JLink-Package without the need to explicitly load a package and NotebookEvaluate is new in version 8 and has some additional options with which one can control the details of the evaluation. See the documentation for the three functions for more information... hth, albert