Installer for local network!

Upload Photoshop Scripts, download Photoshop Scripts, Discussion and Support of Photoshop Scripts

Moderators: Tom, Kukurykus

User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Installer for local network!

Post by Kukurykus »

How to use this script:

You are in local network with server you keep your scripts on and there are also many other computers. You want to help users of your network they work with more efficiency. You write scripts and give out each to them. You still write new and new scripts and this is so boring you each time have to individually give them to each of your users, and additionally personally dig to some Photoshop folders and copy into new content.

This script has to let automate this all. There are few conditions:

- presets folder (you find it in Photoshop folder), and all Starup Scripts folders (you find in Common Files / Adobe folder) must be seen and available fully in your local network, otherwise this script can't copy to them its content.
- all computers in your network should have similar names, so if there are for example Kukurykus-1, Kukurykus-2, Kukurykus-3, Kukurykus-4, Kukurykus-5 and so forth it's okey. The most important is that first main word was common for all of them, and next part so -(number) was different. Other example to make it clear: MAWI-1, MAWI-2, MAWI-3, MAWI-4, MAWI-5, MAWI-6, MAWI-7 and again, so on.

If there are many versions of Photoshop it's no matter. There may be even many Photoshop versions on one computer. If so, the this script makes new Folder "Repository" in each of 'Presets' Folder and then create an alias to scripts on your server. Additionally if there is startup.jsx on your server, only this file will be sent to each version of Photoshop appriopate folder generally existing as "Startup Scripts (number)" in "Common Files / Adobe" Folder.

The only thing you have to do is to specify in initial script form how many computers there are in the local network, what is the common name of each of them, and the path to scripts folder on the server.

Basicly you have to create on some computer / server folder which path should be a little like this: //someServer/c/someFolder/(...)/Scripts where after someFolder there may be other deeper one(s) or the next one will be Scripts (or any other if you don't want this name). The same is with the name of disk and server. They don't have to be c and someServer like in this example. When you have it done put there some scripts, even other stuff like all other kind of files. If you want your user used startup.jsx script, create some and put to that server folder too. It will be sent in proper place after you launch the script. At the end Scripts from server will be available in Photoshop 'File' / ' Scripts' (PS must be restarted!)

If you can't tackle with running this script and have some questions I'm here to help :D

Code: Select all

try {
#target photoshop
bringToFront()

function rw(v1, v2, v3) {v2.open(v1), v1 < 'w' ? v3 = v2.read() : v2.write(v3), v2.close(); return v3}
function SPC(v) {spc = ''; while (spc.length < v) {spc += '\u00A0'}; return spc};

(function() {
(win = new Window("dialog" )).center(), win.margins = 2, win.spacing = 3, rtn = false
win.add('statictext {text: "Press OK if you want this script to create aliases in Photoshops \\"presets\\" folders installed on computers of your local web."}')
win.add('statictext {text: "Thanks to these aliases users of your web will be able to use all scripts and related to them files you keep on your server."}')
win.add('statictext {text: "This script will aslo send start - up script file to all your Startup Scripts foders in Program Files (x86)/Common Files/Adobe/"}')
win.add ("panel", [0,0,666,3]), grp = win.add('group'), grp.orientation = "row"
grp.add("button", undefined, "OK").active = true, grp.add ('statictext {text: ""}', ["", "", 485, ''])
grp.add("button", undefined, "Cancel").onClick = function () {win.close(), rtn = true}, win.show(); if (rtn) return

system("hostname > %HOMEPATH%/desktop/hostname.txt"), hn = rw('r', fle = File('~/Desktop/Hostname.txt')), fle.remove();

(win = new Window("dialog" )).center(), win.margins = 5, win.spacing = 5, rtn = false
grp1 = win.add('group'), grp1.add('statictext {text: "Your local web No. of comps:"}')
a1 = grp1.add ('edittext {preferredSize: [24, 19], active: true}'); a1.text = ''

grp1.add('statictext', undefined, SPC(2) +'and Computer\'s Name*:')
a2 = grp1.add ('edittext {preferredSize: [73, 19]}'); a2.text = String(hn).match(/.*(?=\n)/)

grp2 = win.add('group'), grp2.add('statictext {text: "Your scripts:"}')
grp2.add('statictext {text: "//"}'), a3 = grp2.add ('edittext {preferredSize: [92, 19]}'); a3.text = 'computerName'
grp2.add('statictext {text: "/"}'), a4 = grp2.add ('edittext {preferredSize: [15, 19]}'); a4.text = 'c'
grp2.add('statictext {text: "/"}'), a5 = grp2.add ('edittext {preferredSize: [69, 19]}'); a5.text = 'someFolder'
grp2.add('statictext {text: "/"}'), a6 = grp2.add ('edittext {preferredSize: [44, 19]}'); a6.text = 'Scripts',
grp2.add ("button", [0,0,28,19], "OK", {name:'close'}), win.add ("panel", [0,0,430,3])

win.add('statictext {text: "* There must be common word for all comps! For ex. if there are Kukurykus-1,"}')
win.add('statictext {text: "Kukurykus-2, Kukurykus-3 etcetera the name to type in to blank is: Kukurykus"}')
win.show(), a1 = +a1.text, a2= a2.text

bgn = "File(((xst = File(bgn = '//" + a3.text + "/" + a4.text + "').exists) ? bgn : '') + '/" + a5.text + "/' + src = a6.text)";
kom = [], KOM = [], SCR = (s1 = File((evl = eval(bgn)) + scr = '/Startup.jsx')).exists, SRC = (s2 = File(evl)).exists
function chk() {/P.*p/.test(an = app.name) ? refresh() : ((+i == 0) ? $.sleep(600) : $.sleep(300))}

function sui1() {
(win = new Window("palette")).center(), win.margins = [0, 5, 5, 5], win.alignChildren = "left"
for(i = 1; i <= a1; i++) {kom.push((SPC(i < 10 ? 5 : 5) + nme = a2 +'-') + i), grp = win.add('group'), grp.add('statictext {text: ""}'), CBx = grp.add('checkbox', undefined, '\u00A0' + kom[i - 1])}
grp2 = win.add('group'), grp2.add('statictext {text: ""}'), grp2.add('progressbar', [0, 0, CBx.preferredSize.width - 5, 16], 0, Array(a1).length); return win
}

if (SCR || SRC) {
SUI = sui1(); SUI.show(), chk()
for(i = 0; i <= a1 - 1; i++) {
if ((srv = File(('//' + NME = nme + (i + 1)) + '/c')).exists) {
for(j = 0; j < (PFs = srv.getFiles(/program%20files(%20\(x86\))?/i)).length; j++) {
if (SCR && PFs[j] == PFs[1]) {
try {
for(k = 0; k < (SSs = File(PFs[j] + '/Common Files/Adobe').getFiles(/startup/i)).length; k++) {
File(s1).copy(SSs[k] + (+String(SSs[k]).slice(-1) ? '/Adobe%20Photoshop' : '') + scr)
}
}
catch (err1) {}
}
if (SRC && (adb = File(PFs[j] + '/Adobe')).exists) {
try {
for(l = 0; l < (psp = adb.getFiles(/adobe%20photoshop/i)).length; l++) {
(mms = File((rep = psp[l].getFiles(/presets$/i)[0]) + ((function() {if (!File(rep + (r = '/Repository/')).exists) Folder(rep + r).create()})(), (r + src)))).createAlias((function(){if (!File(mms).exists) return s2})())
}
}
catch (err2) {}
}
}
SUI.children[i].children[1].value = true
}
else KOM.push(NME)
SUI.children[a1].children[1].value = i + 1, SUI.children[i].children[1].active = true, chk(); if (i == a1 - 1) $.sleep(450)
}
SUI.close()
}

function sui2() {
win = new Window("palette", ); win.center(); win.margins = [1, 0, 1, 10], win.spacing = 0, win.add('statictext', undefined, SPC(3) +'No connection with:');
grp = win.add('group'), grp.add('statictext {text: ""}'), wh = grp.add("listbox", undefined, kom, {multiselect: true}), wh.preferredSize.width = 114, wh.preferredSize.height = 17.83 * a1; win.show(), chk()
for(i = 0; i <= a1 - 1; i++) {if (KOM.length && i + 1 == KOM[0].match(/\d+/)) KOM.shift(), win.children[1].children[1].selection = i, chk(); $.sleep (450)}
}

KOM.length ? sui2() : alert('Read instructions at https://forums.adobe.com/thread/2259751.')

if (an) $.sleep(3000), photoshop.quit()
})()
}catch(err) {
alert('Cancellation.')
}
Attachments
Installer.rar
(2.33 KiB) Downloaded 593 times
Last edited by Kukurykus on Sat Jan 07, 2017 1:21 pm, edited 1 time in total.
User avatar
Jaroslav Bereza
Posts: 38
Joined: Tue Dec 27, 2016 7:22 pm

Re: Installer for local web!

Post by Jaroslav Bereza »

It took a while before I realized that web = network :-)
If you will use web instead network it can be a bit confusing I guess.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Installer for local network!

Post by Kukurykus »

I chagned all 'web' words to 'newtwork' in original post. A script I left untouched. Anyway why there is then common word 'website', not 'newtworksite'? :D

Btw is this script working for you if you had chance to check it? Are you Win or Mac user? If mac could you or someone tell me how this path should look like they were correct and working: //someServer/c/someFolder/(...)/Scripts

Are there in Macintosh the same paths like on Windows to these folders:

/c/Common Files/Adobe/Startup Scripts/
/c/Program Files (x86)/Adobe/Adobe Photoshop/
/c/Program Files/Adobe/Adobe Photoshop/
User avatar
Jaroslav Bereza
Posts: 38
Joined: Tue Dec 27, 2016 7:22 pm

Re: Installer for local network!

Post by Jaroslav Bereza »

I don't have another computers in local network which needs Photoshop. And at work we have Remote Desktop(RDP) with installed Photoshop so if somebody need Photoshop he can connect virtually. So you have installed Photohsop only in one PC and anyone can access to PS from their PCs so need copy scripts only once. Anyway they use PS only few times in week for small tasks.