Copy link to clipboard
Copied
Hey
I'm in need of running script in photoshop without it
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
Why don't you make part of script that edits that .txt file to update of necessary line?
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.
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
Copy link to clipboard
Copied
Why don't you make part of script that edits that .txt file to update of necessary line?
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...
Copy link to clipboard
Copied
It's not in secure only read Program Files folder, but in read/write User Preferences folder.
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();
*/
}
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()
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Hello! I'm having the same problem. I need to run a script but the dialog appears. I'm using Power Automate infinite loop to accept it, but I would like to remove the dialog.
I tried to create the PSUserConfig.txt but didn't worked. I'm using Photoshop 2023.
Even if the user config worked, how the Photoshop would run that editing script? It will need also to confirm to run the script in the dialog box, don't
Thanks!
Copy link to clipboard
Copied
How are you running the script?
As suggested by @c.pfaffenbichler @the script events manager is the first thing that comes to mind:
https://prepression.blogspot.com/2021/10/photoshop-script-events-manager.html?m=1