Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 18 down vote accepted

The straightforward way to discriminate is to use $LicenseType, (unfortunately undocumented and not even WolframLanguageData knows about it). Deploying the following line as a CDF file and opening it in various environments provides the following results (thanks for Oleksandr's comment):

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

(* Mathematica 8-10 *)           {"Professional", False, False}
(* CDF Player *)                 {"Player", False, False}
(* Firefox w/ browser plugin *)  {"Professional", True, True}
(* Player Pro *)                 {"Player Pro", False, False}

For more on $LicenseType, see other thread.


As of version 10, one can also use $EvaluationEnvironment, answering a different, but related question. It returns 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

Please feel free to add to the lists if you know other licenses/environments.

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 '14 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 '14 at 14:59
    
I still think that your answer correctly answers my question, but in the current form it isn't very clear as the description of $EvaluationEnvironment is too prominent (IMO), considering in the "final" implementation seems to be a solution to a different while related problem. I would consider the use of $LicenseType is the answer to my question as it was stated. As $EvaluationEnvironment is of course also interesting, I wouldn't want that to be removed, but I'd suggest to probably make more clear that it actually is $LicenseType which answers the question. – Albert Retey Jun 8 at 8:26
    
@Albert Done. I'm quite disappointed that I couldn't figure out more about $LicenseType though. Perhaps someone else. – István Zachar Jun 8 at 9:49

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
1  
In Wolfram CDF Player Version 10 this gives "Professional". – Rolf Mertig Feb 19 '15 at 20:09

These are undocumented, but I doubt they will change much going forward... I think they are available in v9 or later, but I don't recall exactly when they were introduced...

FE`Evaluate@FEPrivate`PlayerQ[]
FE`Evaluate@FEPrivate`PlayerProQ[]

FEPrivate`PlayerQ[] returns True when the document is running in CDF Player mode. FEPrivate`PlayerProQ[] returns True when the document is an EnterpriseCDF or is running inside of an activated copy of CDF Player.

If you use them inside of a Dynamic, you probably would not need to use the FE`Evaluate wrapper.

share|improve this answer
    
thanks, great finding. As none of the other solutions are documented I think this is just as good as any of them. I'll try to experiment with that to learn whether it fits my purposes as good or better than the other possibilities... – Albert Retey Jun 8 at 16:52

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.