MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Notebook that auto-executes when opened?

  • To: mathgroup at
  • Subject: [mg97319] Re: [mg97286] Re: Notebook that auto-executes when opened?
  • From: Andrzej Kozlowski <akoz at>
  • Date: Wed, 11 Mar 2009 04:20:26 -0500 (EST)
  • References: <gp2bgq$911$> <gp2qf0$d07$> <>

On 10 Mar 2009, at 11:33, AES wrote:

> AES wrote:
>> Is it possible to set an option for a notebook such that it  
>> automatically
>> begins executing when opened? -- that is, when the nb icon is dbl- 
>> clicked?
> and Jens-Peer Kuska <kuska at> replied:
>> no, it would be the first Mathematica written virus
>> My favorite command would be
>> DeleteFile/@ FileNames["*.*", {"C:\\"}, 4]
> Interesting point, and one I'd certainly not thought of -- although I
> was asking about creating this capability in notebooks that I'd write
> myself, for myself, not ones to be distributed to others.
> And in any case, if you were malevolent in this fashion, could you not
> fairly easily hide your favorite command within a closed but still
> executable cell within some large and apparently benevolent nb, which
> you might then make available to other people for them to use in doing
> some apparently useful task?
> Or perhaps bury it in a Mathematica package, or demonstration, or ???
> that was then called and executed by this benevolent program?  (I'm  
> not
> skilled enough in the complexities of Mathematica to know just what  
> can
> and can't be included in structures other than notebooks.)
> Related thought:  Should Mathematica perhaps have an option or
> preference (which is normally set to ON by default) under which your
> favorite command, and others like it, would always trigger an "_Are  
> you
> sure_ you want to do this?" dialog before executing?  Seems to me many
> of the other apps I use have some capability like this, for protection
> against accident as much as malevolence.

Yes, one can do all of the above, which is why the Wolfram  
Demonstration Site has features designed to prevent users uploading  
demonstrations containing potentially malicious code. I assume  
packages downloaded from MathSource should also be safe (but I would  
be a little more doubtful in this case than in the case of the  
Demonstrations Project).
Other than that, if you download a notebook or a package and run it on  
your computer without carefully examining its contents you run exactly  
the same risks as when running any program you download form the  

I don't see the point of the last idea. A mathematica notebook is just  
an ASCI file which may contain executable code. Mathematica has no way  
of distinguishing code that can actually do something from, say, a  
list of numbers, symbols etc, that have been put into an Input Cell. I  
can't imagine how such messages could tell anyone anything would be of  
the slightest use in deciding whether to evaluate an input cell or  
not, without examining its contents. Of course it would be possible to  
write a package that would attempt to analyze any piece of code for  
malicious potential, but it could never be foolproof and in fact would  
be easy to get around for any reasonably skilled Mathematica programmer.

Andrzej Kozlowski


  • Prev by Date: Re: Re: Bug in Pattern Matching with Condition?
  • Next by Date: Re: simple vector plots
  • Previous by thread: Re: Notebook that auto-executes when opened?
  • Next by thread: Re: Notebook that auto-executes when opened?