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

Start Photoshop & run script without user interaction

Engaged ,
Jan 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

Hey

 

I'm in need of running script in photoshop without it 

Dariusz1989_0-1641819345430.png

Asking for that.

I want to start PS & run Script, ur run script in already running PS.

I don't want to add settings entry in PSUserConfig.txt file. 

Any ideas how that can be done?

I know that vscode/extendtoolkit are able to send messages to PS without that "pop-up" as thats how we run scripts there... any idea how to piggy back off them?

My current command

"C:\Program Files\Adobe\Adobe Photoshop 2022\Photoshop.exe" -r "C:\Users\Master\Desktop\yaya.jsx"

Regards

Dariusz

TOPICS
Actions and scripting

Views

1.6K

Translate

Translate

Report

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

LEGEND , Jan 10, 2022 Jan 10, 2022

Why don't you make part of script that edits that .txt file to update of necessary line?

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

If I undersatand you correctly you could try using 

File > Scripts > Script Events Manager 

instead and link the Script to the »Start Application«-event. 

Votes

Translate

Translate

Report

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
Engaged ,
Jan 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

Hey

Interesting idea, thank you! But it wont work, I want to send different scripts /etc.

I dont want user to have to configure anything except for just running my app & that run scripts in ps.

Regards

Dariusz

Votes

Translate

Translate

Report

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 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

Why don't you make part of script that edits that .txt file to update of necessary line?

Votes

Translate

Translate

Report

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
Engaged ,
Jan 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

Id rather not edit photoshop user preferences just so I can hide my evil scripts 😄 Also if the file is located in secure loca tion /program files. I probably wont be able to anyway...

 

Votes

Translate

Translate

Report

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 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

It's not in secure only read Program Files folder, but in read/write User Preferences folder.

Votes

Translate

Translate

Report

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 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

I'm sure that @Dariusz1989 has this well in hand, however, I like using these discussions as a learning exercise and wanted to expore the solution presented by @Kukurykus. The following was a personal exercise, I can confirm from testing that the following works on CC2020 – CC2022 on both Mac and Win.

 

/*
Warn running scripts config - universal.jsx
v1.1 updated 12th January 2022
https://community.adobe.com/t5/photoshop-ecosystem-discussions/start-photoshop-amp-run-script-without-user-interaction/td-p/12645933
*/

/* https://helpx.adobe.com/photoshop/kb/enable-optional-extensions-photoshop-cc.html */

#target photoshop

var os = $.os.toLowerCase().indexOf('mac') >= 0 ? "mac" : "windows";
if (os === 'mac') {
    var appNameMac = app.path.fsName.replace(/^\/.+\//, '');
    var userConfigFile = new File("~/Library/Preferences/" + appNameMac + " Settings/PSUserConfig.txt");
    //var userConfigFile = new File(app.preferencesFolder + "/PSUserConfig.txt");
    //alert(userConfigFile.fsName);
    if (userConfigFile.exists)
        userConfigFile.remove();
    userConfigFile.open("w");
    userConfigFile.encoding = "UTF-8";
    userConfigFile.lineFeed = "Unix";
    userConfigFile.writeln("WarnRunningScripts 0");
    userConfigFile.close();
    /*
    var userConfigFile = Folder("~/Library/Preferences/" + appNameMac + " Settings/");
    //var userConfigFileDir = Folder(app.preferencesFolder);
    //alert(userConfigFileDir.fsName);
    userConfigFileDir.execute();
    userConfigFile.execute();   
    */

} else {
    var appNameWin = app.path.fsName.replace(/^.+\\/, '');
    var userConfigFile = new File("~/appData/Roaming/Adobe/" + appNameWin + "/" + appNameWin + " Settings/PSUserConfig.txt");
    //var userConfigFile = new File(app.preferencesFolder + "/PSUserConfig.txt");
    //alert(userConfigFile.fsName);
    if (userConfigFile.exists)
        userConfigFile.remove();
    userConfigFile.open("w");
    userConfigFile.encoding = "UTF-8";
    userConfigFile.lineFeed = "Windows";
    userConfigFile.writeln("WarnRunningScripts 0");
    userConfigFile.close();
    userConfigFile.execute();
    /*
    var userConfigFileDir = Folder("~/appData/Roaming/Adobe/" + appNameWin + "/" + appNameWin + " Settings/");
    //var userConfigFileDir = Folder(app.preferencesFolder);
    //alert(userConfigFileDir.fsName);
    userConfigFileDir.execute();
    userConfigFile.execute();
    */
}

 

 

Votes

Translate

Translate

Report

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 11, 2022 Jan 11, 2022

Copy link to clipboard

Copied

wrs = 'WarnRunningScripts '; function rw(v1, v2, v3) {
	v2.open(v1), v1 =='r' ? v3 = v2.read()
	: v2.write(v3); return v3
}

if ((fle = File(preferencesFolder + '/PSUserConfig.txt')).exists)
	cntnt = ('\n' + rw('r', fle) + '\n').split(RegExp(wrs + '[01]')),
	(cntnt.length > 1 && rw('w', fle, cntnt.join(wrs + '0')
	.slice(1, -1))) || rw('a', fle, '\n' + wrs + '0')
else rw('a', fle, wrs + '0'); fle.close()

Votes

Translate

Translate

Report

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 12, 2022 Jan 12, 2022

Copy link to clipboard

Copied

@Kukurykus 

 

Haha, I obviously didn't recall that there is a predefined app.preferencesFolder - which is why I did it in such a torturous Rube Goldberg way!

 

I like your approach of updating the existing content, instead of removing and recreating the file with the desired settings (no need to worry about platform specific line endings etc).

 

P.S. Apart from this scripting warning flag, what else could this preference file optionally contain?

Votes

Translate

Translate

Report

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 12, 2022 Jan 12, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 12, 2022 Jan 12, 2022

Copy link to clipboard

Copied

LATEST

Thank you, looking at the info, for the average user removing/rewriting the file is probably a "pretty safe" bet, but as I said, I like your approach better as it is safer.

Votes

Translate

Translate

Report

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