Allow scripts to write file and access network

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
pirelouit
Posts: 18
Joined: January 16th, 2006, 12:08 pm

January 26th, 2006, 8:32 am

Hi! I've seen in some scripts that it is possible to access and edit the preferences, is it possible also for the "allow scripts to write file and access network" preference?

Also, where do you find how to address the preferences, for example

Code: Select all

app.preferences.savePrefAsLong("Main Pref Section", "Pref_JAVASCRIPT_DEBUGGER", 1)
it is not in the documentation... so how did you find the 'correct name', by trial and error?

Thanks
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

January 29th, 2006, 6:11 am

I've tried using a script to turn off the Javascript Debugger pref in the past, with no success. Some prefs work well with scripting, others don't. The whole reason for the "Allow scripts to write files...." pref is presumably to add a degree of security, so I think it's highly unlikely a script could override that. Here's a function from my SearchEffects script that I use to test for access and warn the user:

Code: Select all

	function isNetworkAccessAllowed() {

		var securitySetting = app.preferences.getPrefAsLong("Main Pref Section", "Pref_SCRIPTING_FILE_NETWORK_SECURITY");
		if ( securitySetting != 1) {
			alert ("Unable to save report.\r" + "Go to After Effects > Preferences > General and make sure\r" +
			"\"Allow Scripts to Write Files and Access Network\" is checked.");
		}
		// returns true if security setting pref is 1
		return (securitySetting == 1);
	}
Also, using this site's Search to find 'pref' brought up some useful threads including:
http://www.aenhancers.com/viewtopic.php?t=90
http://www.aenhancers.com/viewtopic.php?t=119

And you're right, this isn't documented (probably because it doesn't work very well). The only documented stuff refers to creating your own user definable prefs (i.e preferences for a script)

Paul T
davestewart
Posts: 114
Joined: March 10th, 2005, 5:50 am
Location: London, UK
Contact:

January 29th, 2006, 6:14 pm

This works for me:

Code: Select all

// functions
	function getDebuggerState(){ 
		return Boolean(app.preferences.getPrefAsLong("Main Pref Section", "Pref_JAVASCRIPT_DEBUGGER"))
		}


	function setDebuggerState(state){ 
		app.preferences.savePrefAsLong("Main Pref Section", "Pref_JAVASCRIPT_DEBUGGER", Number(state)) 
		app.preferences.saveToDisk(); 
		app.preferences.reload(); 
		} 

// script 
	setDebuggerState(false) 

	try{thisWillBreakIt}
	catch(e){} 

	alert(getDebuggerState())
[/code]
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

January 30th, 2006, 2:04 am

Doh! I was remembering my first attempts, before learning about saveToDisk() and reload(). Here's the thread where I originally helped you out with the exact same thing: viewtopic.php?t=189

I still don't think trying to change the network pref will work.
davestewart
Posts: 114
Joined: March 10th, 2005, 5:50 am
Location: London, UK
Contact:

January 30th, 2006, 1:09 pm

Hilarious! Thanks ...
stweed
Posts: 12
Joined: February 18th, 2016, 2:35 pm

April 25th, 2019, 12:28 pm

Paul Tuersley wrote:
January 29th, 2006, 6:11 am
I've tried using a script to turn off the Javascript Debugger pref in the past, with no success. Some prefs work well with scripting, others don't. The whole reason for the "Allow scripts to write files...." pref is presumably to add a degree of security, so I think it's highly unlikely a script could override that. Here's a function from my SearchEffects script that I use to test for access and warn the user:

Code: Select all

	function isNetworkAccessAllowed() {

		var securitySetting = app.preferences.getPrefAsLong("Main Pref Section", "Pref_SCRIPTING_FILE_NETWORK_SECURITY");
		if ( securitySetting != 1) {
			alert ("Unable to save report.\r" + "Go to After Effects > Preferences > General and make sure\r" +
			"\"Allow Scripts to Write Files and Access Network\" is checked.");
		}
		// returns true if security setting pref is 1
		return (securitySetting == 1);
	}
Also, using this site's Search to find 'pref' brought up some useful threads including:
http://www.aenhancers.com/viewtopic.php?t=90
http://www.aenhancers.com/viewtopic.php?t=119

And you're right, this isn't documented (probably because it doesn't work very well). The only documented stuff refers to creating your own user definable prefs (i.e preferences for a script)

Paul T
I noticed in the release notes of CC 2019 they moved this option to another panel in the settings. Is there an easy way to account for this so that it works for every version of AE?
Post Reply