Message Boards Message Boards

Avoiding ad "Enable Dynamics" in CDF Player

GROUPS:

I build my .cdf file from the output of a file .nb (which has evidently interactivity) using File-> Export- cdf> standalone ...). When I open it with CDFPlayer always ask me "Enable Dynamics" (this can be very cumbersome for students).

Q: How I can always build my .cdf without this annoying ad?

I used the option TrustByDefault but it does not work.

I used the option TrustedPath but it does not work.

Help!

Thank you.

POSTED BY: Ernesto Espinosa
Answer
2 years ago

Hola Ernesto, evaluate this (I tested on Windows 10 with Mathematica 10.4.1, but it should also work on Mac):

If[$OperatingSystem==="Windows",Quiet@Run["taskkill /im WolframCDFPlayer.exe /f"]];Function[cdfName,
CDFDeploy[cdfName,#,
                           Method -> "Standalone",WindowSize->{600,300}, "Target"->"CDFPlayer"
          ]&@DocumentNotebook[#,Saveable->False,Magnification->1.5]&@
DynamicModule[{tbd}
,

Column[{
Button["Set option to TrustByDefault -> True ",

SetOptions[$FrontEnd,"NotebookSecurityOptions"->{"TrustByDefault"->True,"UntrustedPath"->{}}];
tbd=True;,
Method -> "Queued"
],
Button["Set option to TrustByDefault -> False ",
SetOptions[$FrontEnd,"NotebookSecurityOptions"->{"TrustByDefault"->False}];
tbd=False;,
Method -> "Queued"
],TextCell@
Grid[{
{Style["Do not ask for Enable Dynamics: ","Text",ShowStringCharacters->False],Dynamic[tbd(*,UpdateInterval\[Rule]1*)],SpanFromLeft}}, Alignment->Left]
}],Initialization:>(tbd="TrustByDefault"/.(NotebookSecurityOptions/.Options[$FrontEnd,NotebookSecurityOptions]))];
If[$OperatingSystem==="Windows",
With[{cdfExe = 
FileNames["WolframCDFPlayer.exe",FileNameJoin[{$TopDirectory//ParentDirectory//ParentDirectory, "Wolfram CDF Player"}],2]/.{cdf_String,___}:>cdf
},
ReadList["! start \"\" \"" <>cdfExe<>"\""<>" " <> cdfName,"String"]
],
SystemOpen@cdfName
]
]@"SetPlayerSecurityToTrustByDefault.cdf";

Then click "Enable Dynamics" in the CDF

enter image description here

Now click the first button

enter image description here

This will open

enter image description here

where you should click "Yes".

and this it. You will never be asked about "Enable Dynamics" again when opening CDFs.

Rolf

POSTED BY: Rolf Mertig
Answer
1 year ago

Update: this also works in Mathematica 11.x

Obviously this is done at your own risk and after disabling security for CDFs you have to be careful which CDFs to open.

However, I usually open my own CDFs, and, trusting me, I never had a problem and I am not bothered by "Enable Dynamics" anymore.

I also attach the CDF for simplicity.

Attachments:
POSTED BY: Rolf Mertig
Answer
8 months ago

I would be great to be able to disable the "Enable Dynamics" warning but only for the Enterprise CDF files that I create for my team. These CDF files include a (* NotebookSignature (...) *) at the end that I think is suppose to avoid this, but not for my CDFs that read and write files.

POSTED BY: Gustavo Delfino
Answer
8 months ago

Suppose you ask your team to put the CDFs into a common "myTeam" folder on your network drive then you could try to adapt my code to only add this folder to the trusted path, see also here.

However, I ask myself sometimes, why there is "Enable Dynamics" anyway, for Enterprise CDF files? The security argument I do not buy. I doubt many hackers are using Enterprise Mathematica.

POSTED BY: Rolf Mertig
Answer
8 months ago

I have come across this issue, and also tested it. It appears the receiver of the CDF will see the "Enable Dynamics" warning only if it is opened under Mathematica (which requires a license).

If, on the other hand, the receiver opens it under the Free CDF Player (which do not require a license) there will be no warning. But the supposedly dangerous functionality will not be available for user interaction.

Whats dangerous? Functions like ToExpression, SetOptions etc.

POSTED BY: Hans Milton
Answer
8 months ago

Group Abstract Group Abstract