Skip to main content
Kukurykus
Legend
December 6, 2017
Answered

$.getenv('Path')

  • December 6, 2017
  • 2 replies
  • 4698 views

$.getenv('Path')

- when you launch Photoshop and and run a script with above code or target Photoshop from Extendscript the first path from all displayed will be to Photoshop

- when you launch Bridge and and run a script with above code or target Bridge from Extendscript the first path from all displayed will be to Bridge

but:

- when you launch Photoshop and then run Bridge from Photoshop manually (File / Browse in Bridge...) or by script were is command to launch Bridge

and you use $.getenv('Path') whatever from Extendscript with targeted Bridge or from the script the first path there will be displayed won't be to Bridge but Photoshop!

- when you launch Bridge and then run Photoshop from Bridge manually (File / Open with Photoshop) or by script were is command to launch Photoshop

and you use $.getenv('Path') whatever from Extendscript with targeted Photoshop or from the script the first path there will be displayed won't be to Photoshop but Bridge!

Well it makes problem! Because no matter you run Photoshop and Bridge or Bridge and Photoshop,

where the second program is ran from your system or from first program it always should gives path of the program you target or run script from.

Scenario:

Some script works in Photoshop/Bridge but then needs information from Bridge/Photoshop.

a) If both programs were launched separately from system (Windows / OS), and then $.getenv('Path') is used all is okey.

b) If only one program was launched from system and second from that program which was lunched first or from the script targeted one program but then calling another $.getenv('Path') end is completely useless!

Is it bug or some specific behaviour? Well some users can open second program from that first or a script will do it. How then chance behaviour of that second program. I mean ho to make it could use $.getenv('Path') like it was launched from system?

For now it seems like first program is kind of parent of that second, like system for programs ran in. I can close by script that second program and use File(<path>).execute() of course to open that second program. Then it will be opened by system.

But it is not a way. If I did that then I had to use a path, which I don't know, so I want to get by $.getenv('Path') which has to tell me path to application I want to open (no matter there is also app.path). It's about finding solution for the problem I'm describing.

So command line and Autohotkey is no an option too, as in their cases I also has to put the path, which I can't know when I don't know were exacactly and what program is installed by someone who uses my script with $.getenv('Path')

Any ideas what can be done in this situation? If there is not then some workaround? and like I asked before is it bug or specific behaviour?

This topic has been closed for replies.
Correct answer SuperMerlin

Why not use :-

alert(decodeURI(Folder.startup));

Bridge does not give anything for app.path;

2 replies

SuperMerlin
SuperMerlinCorrect answer
Inspiring
December 6, 2017

Why not use :-

alert(decodeURI(Folder.startup));

Bridge does not give anything for app.path;

Kukurykus
KukurykusAuthor
Legend
December 6, 2017

@SuperMerlin I didn't read all documention so I didn't know this method. It works well. I can use it instead of getenv('Path'), however I still hope someone find some workaround for the problem I met. Yes app.path does nothing in Bridge (I don't know what happened meantime I thought it doesn't, so if not method you prosopsed I really had problem with some of my scripts other users in my work use...

Legend
December 6, 2017

It is usually difficult for me to understand all the nuances of the problems described in English.

Could you give a maximally simplified example of the scrip (s) where the problem can arise because of the first value change in Path.

I do not have and I do not use Bridge, so I can not check anything. I can only suggest in theory.

Kukurykus
KukurykusAuthor
Legend
December 6, 2017

I wrote my 'question' in notapad then pasted during creating new topic with intention to edit it in some parts as it copied some unexpected spaces between next paragraphs and generally was too long. Unfortunately I found out I can't edit (even unanswered) new topics created myself like that's possible with answers to someone topic/post. I can't understand what is this limitation for? Anyway if I couldn't edit it then I wanted to completely remove my new topic to create it again with corrected content. Well there's no option also for that! So I left ugly looking original topic! It seems only I can do is to create another theard with the same corrected content. So there would be 2 similar topics. What if I find another thing to correct before someone answer? I have to create another topic? It's stupid, but I guess moderators delete those older versions, however that isn't fun, so better if not let users for editing their new created topics then at least give chance to remove them. Is there such option to enable by administrator/moderator in Jive forums or we have to live with this nonsene?

--------------------------------------------------------------------------------------------------------------------------------------------

r-bin you don't need to have bridge. It's sufficient you have Photoshop and ExtendScript toolkit. Just do the following:

1) Open Photoshop from system, then ESTK from system too (or in other order).

2) try this code in ESTK:

$.getenv('Path')

First path will be: C:\ProgramData\Oracle\Java\javapath

3) now thry this code:

#target photoshop

$.getenv('Path')

It's again correct, so first path will be: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\

you can save code from item 3 as script and run from photoshop, it'll give expected result (photoshop path)

4) to display correct path of ESTK calling it from Photoshop it's not so obvious. You can't just use following code ran in Photoshop:

#target estoolkit

alert($.getenv('Path'))

as it displays you Photoshop path in Photoshop (for some reason it doesn't take you to ESTK, and also doesn't open it when it's not launched)

You have to use this code:

BT = '(function BT(v1, v2) {bt = new BridgeTalk(), bt.target = v1, \

bt.body = v2, bt.onResult = function(v) {return res = v.body} bt.send(2)})'

function ge() {alert($.getenv('Path'))}

eval(BT + "('estoolkit', '(' + " + ge.toString() + " + ')()')")

so Bridge Talk, which let you for communication between Adobe applications

(still you don't have to have Bridge to use it as 'BridgeTalk' isn't the same what 'Bridge')

Anyway, when you save above code as script and run from photoshop it show you that 'specific' ESKT path in this case

--------------------------------------------------------------------------------------------------------------------------------------------

Now do it the way one application launches second:

1) Open Photoshop from system and run a script with code you used last time (from Photoshop as well), so:

BT = '(function BT(v1, v2) {bt = new BridgeTalk(), bt.target = v1, \

bt.body = v2, bt.onResult = function(v) {return res = v.body} bt.send(2)})'

function ge() {alert($.getenv('Path'))}

eval(BT + "('estoolkit', '(' + " + ge.toString() + " + ')()')")

it won't display C:\ProgramData\Oracle\Java\javapath in first line of array-like message, but Photoshop path

2) Now close both programs and try it that you open first ESTK and then following code you run as script from system or paste to ESTK editor and play:

#target photoshop

BT = '(function BT(v1, v2) {bt = new BridgeTalk(), bt.target = v1, \

bt.body = v2, bt.onResult = function(v) {return res = v.body} bt.send(2)})'

function ge() {alert($.getenv('Path'))}

eval(BT + "('photoshop', '(' + " + ge.toString() + " + ')()')")

(#target photoshop in first line is needed only when you execute script from system)

however in this case you could use (alerted if ran from system or with/out when from ESTK) simple:

#target photoshop

alert($.getenv('Path'))

it won't display Photoshop path in first line of array-like message, but C:\ProgramData\Oracle\Java\javapath

--------------------------------------------------------------------------------------------------------------------------------------------

well I hope now you understand and give me solution for this problem

Legend
December 6, 2017

How many letters ).
But as far as I understand you did not describe the problem more serious

than the "wrong" output of the function alert($.getenv('Path')).

More serious problems can be? Why do you need to see the path to the application in the first line of the "Path", especially It is not in the system variable "Path"?