Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Within a Mathematica program with a graphical user interface I want to programmatically determine whether the code runs in a full Mathematica, a Player Pro or a CDF-Player. There seem to not be any documented functions which would allow to get that information. I understand that this might be on purpose, as the idea is that it shouldn't matter. At least Mathematica Player Pro provides basically the same functionality as Mathematica. But there are some subtle differences and of course the CDFPlayer has well known limitations.

For the moment I have ways to get that information, but they are all somewhat dirty and/or not very reliable:

  • Look at variables like $InstallationDirectory or $BaseDirectory and check for known directory names
  • Look at SystemInformation[] or Options[$FrontEnd] and use heuristics to get the desired information from what these return.
  • try something that is known to not work with CDF Player (e.g. export data). Will of course not work for a Player Pro.

and of course one could use any combination of these things to get a more reliable result.

Does anyone know a better way to get that information?

share|improve this question
    
Is this what you are looking for? official comparison –  Vitaliy Kaurov Nov 6 '12 at 17:06
    
@VitaliyKaurov I think it is about getting info on the environment the code is running in (i.e. Mathematica, Player etc.) –  Yves Klett Nov 6 '12 at 17:12
10  
Perhaps try $LicenseType ("Professional" for Mathematica; presumably something else for Player) or the supposedly (but not really) deprecated $ProductInformation (gives "ProductIDName" -> "Mathematica" vs. "ProductIDName" -> "MathematicaPlayer"). For the CDF plugin you can check CurrentValue[PluginEnabled]. –  Oleksandr R. Nov 6 '12 at 17:13
1  
Oh, and if you want to figure out if you're running in the plugin/Player sandbox, you can use Developer`$ProtectedMode for that too. –  Oleksandr R. Nov 6 '12 at 17:36
1  
@Ajasja because all of this is undocumented and I don't have the Player installed or the time to test it properly. Whoever does and can state definitively what the results will be in various situations and for different versions of the relevant products is welcome to use my suggestions in their own answer if they wish. –  Oleksandr R. Nov 6 '12 at 19:37
show 4 more comments

2 Answers

up vote 13 down vote accepted

As of version 10, one can use $EvaluationEnvironment returning one of the followings:

"Session"          local interactive session
"RemoteSession"    remote interactive session
"CDF"              standalone CDF
"Script"           script run in batch mode
"Subkernel"        parallel or grid subkernel
"WebEvaluation"    direct URL evaluation
"WebLoad"          evaluation when loading a webpage
"WebAPI"           API called through an HTTP request
"WebForm"          web form
"WebServer"        web server plugin (e.g. JSP)
"CloudCDF"         cloud CDF
"PlugInCDF"        CDF web plugin
"Scheduled"        scheduled task
"WolframLink"      WolframLink call

Version 9 and earlier:

According to @Oleksandr's comment, I deployed the following line as a CDF file and opened it in various environments:

Dynamic@{$LicenseType, Developer`$ProtectedMode, CurrentValue["PluginEnabled"]}

In Mathematica 8.0.4:

{"Professional", False, False}

In the CDF Player:

{"Player", False, False}

Under Firefox using the browser plugin:

{"Professional", True, True}

On Player Pro:

{"Player Pro", False, False}
share|improve this answer
    
Thanks for helping to flesh this out into a useful answer. Another thing I had been wondering is what $LicenseType is for Mathematica for Students or the Home Edition? I don't have either of these products so I can't easily check, but perhaps someone else can fill in the additional details? –  Oleksandr R. Nov 7 '12 at 8:37
    
Great stuff here, I should browse your answer more carefully :P –  Kuba Mar 27 at 14:18
    
Thanks @Kuba; in this case I've just found out about $EvaluationEnvironment while browsing the non-final documentation online. Many things are revealed from weak to weak as they are getting closer to roll out the new version. –  István Zachar Mar 27 at 14:59
add comment

The following

MathLink`CallFrontEnd@FrontEnd`Value["$NotebookLicenseType"]

will distinguish "Player Pro" from just "Player", or Mathematica, which the other methods do not handle if you need to make such a distinction.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.