Skip to main content
Tilles
Inspiring
November 5, 2021
Answered

Auto detection of "Allow Scripts network access"

  • November 5, 2021
  • 1 reply
  • 578 views

hi guys,
I've noticed that when you run a script that needs access to the network, and this option is unchecked, it seems that After Effects auto detect it and pop an alert for the user. Is that a solution that was developed recently? I have many scripts that handle this issue by itself, but now they're not working as expected.

This topic has been closed for replies.
Correct answer Tilles

hi guys, following up the issue.
I discovered that the AEscripts framework is throwing the error, before the script starts.

I implemented their gateway few days ago, and didnt realize the framework is checking somehow for network access.
thanks anyway

1 reply

Meng Zhiqun
Inspiring
November 5, 2021

You can try this.

function isSecurityPrefSet(){ // check if the setting allowing script to overwrite is active.
    try{
        var securitySetting = app.preferences.getPrefAsLong("Main Pref Section","Pref_SCRIPTING_FILE_NETWORK_SECURITY");
        return (securitySetting ==1);
    }catch(e){
        alert("Error in isSecurityPrefSet function\n" + e.toString());
    }
}

 

Call it by using this.

if(!(isSecurityPrefSet())){ //check if the setting allowing script to overwrite is active.
    alert("This script needs access to write files.\n"+"Go to \"General\" OR \"Scripting & Expression\" panel in App preferences to make sure\n"+"'Allow Scripts to Write Files and Access Network' is checked");
    app.executeCommand(2359);
}else{
    //do this
}
Tilles
TillesAuthor
Inspiring
November 5, 2021

hi mengopoo, thanks for the answer.
I'm using this piece of code, but the problem is that AE pops an alert before running my code, saying that the "script may need access to the network" and this alert breaks the script flow.
I thought it's was a great idea putting it inside a try / catch, but testing it didnt change anything.
anyway, if I find the answer, I'll post here. cheers