Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I check whether if "Allow Scripts to Write Files and Access Network" is enable using Script?

Contributor ,
Jan 20, 2020 Jan 20, 2020

I want to check if Allow Scripts to Write Files and Access Network eneabled via scripting. It is doable, I've seen some scripts do that check before run some functions. How can I check that radio button inside preferences settings???

TOPICS
How to , Resources , Scripting , User interface or workspaces
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jan 22, 2020 Jan 22, 2020

Here's a barebone function that will check if Allow Scripts to Write Files and Access Network is enabled or disabled

function canWriteFiles() {
	var appVersion, commandID, scriptName, tabName;

	appVersion = parseFloat(app.version);

	commandID = 2359;
	tabName = 'General';
	if (appVersion >= 16.1) {
		commandID = 3131;
		tabName = 'Scripting & Expressions';
	}

	if (isSecurityPrefSet()) return true;

	scriptName = (script && script.name) ? script.name : 'Script';
	alert(message = scriptName + '
...
Translate
Community Expert ,
Jan 20, 2020 Jan 20, 2020

You will find the option in the Preferences>Scripting and Expressions panel:

Screenshot_2020-01-20 21.45.48_mGHaHK.png

In previous versions of AE the option is in the Preferences>General Panel just below the middle.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 20, 2020 Jan 20, 2020

I'm asking about scripting. How can I check if it enabled or not using extendScript??

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 20, 2020 Jan 20, 2020

As far as I know, there is no connection between scripts and preferences. The user will just get an error. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 21, 2020 Jan 21, 2020

Well, you have access to the prefs file via the respective functions. Otherwise any function that is dependent on network access like opening a socket connection will simply trigger a warning. Nothing particulalrly smart about it required.

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 22, 2020 Jan 22, 2020

Here's a barebone function that will check if Allow Scripts to Write Files and Access Network is enabled or disabled

function canWriteFiles() {
	var appVersion, commandID, scriptName, tabName;

	appVersion = parseFloat(app.version);

	commandID = 2359;
	tabName = 'General';
	if (appVersion >= 16.1) {
		commandID = 3131;
		tabName = 'Scripting & Expressions';
	}

	if (isSecurityPrefSet()) return true;

	scriptName = (script && script.name) ? script.name : 'Script';
	alert(message = scriptName + ' requires access to write files.\n' +
		'Go to the "' + tabName + '" panel of the application preferences and make sure ' +
		'"Allow Scripts to Write Files and Access Network" is checked.');

	app.executeCommand(commandID);

	return isSecurityPrefSet();

	function isSecurityPrefSet() {
		return app.preferences.getPrefAsLong(
			'Main Pref Section',
			'Pref_SCRIPTING_FILE_NETWORK_SECURITY'
		) === 1;
	}
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 22, 2020 Jan 22, 2020
LATEST

Thank you so much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines