In a different post X showed how to access an environment variable.
Code: Select allvar cname = $.getenv("COMPUTERNAME");
Is there a way to set a new environment variable?
Mike
Setting an environment variable with JS
-
xbytor
Setting an environment variable with JS
I was about to say "No", but they added this to CS3:
Code: Select all$.setenv (envname, value)
Very cool. It's nice to see the APIs getting filled out in some places like this.
-X
Code: Select all$.setenv (envname, value)
Very cool. It's nice to see the APIs getting filled out in some places like this.
-X
-
Mike Hale
Setting an environment variable with JS
Thanks X,
Have you done any thing using the variable 'JSINCLUDE'?
I can't get it to work in CS2.
Mike
Have you done any thing using the variable 'JSINCLUDE'?
I can't get it to work in CS2.
Mike
-
xbytor
Setting an environment variable with JS
I expect that JSINCLUDE would have to be set _before_ PS is launched. At least, that would be typical of how environment variables are used. Setting an environment variable in a process often will only effect and subprocess that is later created. The exact behavior depends on the programming language and environment.
-X
-X
-
Mike Hale
Setting an environment variable with JS
Yes it needs to be set before Photoshop is opened. And ESKT as well if you are using it.
However even with a restart I can't get it to work. I guess this is yet another item that Adobe didn't finish before CS2 shipped.
I'll try it in CS3 next.
Mike
However even with a restart I can't get it to work. I guess this is yet another item that Adobe didn't finish before CS2 shipped.
I'll try it in CS3 next.
Mike
-
undavide
Setting an environment variable with JS
For some reason I can't get anything from this list but "null":
Code: Select all$.writeln("ALLUSERSPROFILE == "+ $.getenv("ALLUSERSPROFILE"));
$.writeln("APPDATA == "+ $.getenv("APPDATA"));
$.writeln("CommonProgramFiles == "+ $.getenv("CommonProgramFiles"));
$.writeln("COMPUTERNAME == "+ $.getenv("COMPUTERNAME"));
$.writeln("ComSpec == "+ $.getenv("ComSpec"));
$.writeln("HOMEDRIVE == "+ $.getenv("HOMEDRIVE"));
$.writeln("HOMEPATH == "+ $.getenv("HOMEPATH"));
$.writeln("LOGONSERVER == "+ $.getenv("LOGONSERVER"));
$.writeln("NUMBER_OF_PROCESSORS == "+ $.getenv("NUMBER_OF_PROCESSORS"));
$.writeln("OS == "+ $.getenv("OS"));
$.writeln("Os2LibPath == "+ $.getenv("Os2LibPath"));
$.writeln("Path == "+ $.getenv("Path"));
$.writeln("PATHEXT == "+ $.getenv("PATHEXT"));
$.writeln("PROCESSOR_ARCHITECTURE == "+ $.getenv("PROCESSOR_ARCHITECTURE"));
$.writeln("PROCESSOR_IDENTIFIER == "+ $.getenv("PROCESSOR_IDENTIFIER"));
$.writeln("PROCESSOR_LEVEL == "+ $.getenv("PROCESSOR_LEVEL"));
$.writeln("PROCESSOR_REVISION == "+ $.getenv("PROCESSOR_REVISION"));
$.writeln("ProgramFiles == "+ $.getenv("ProgramFiles"));
$.writeln("SystemDrive == "+ $.getenv("SystemDrive"));
$.writeln("SystemRoot == "+ $.getenv("SystemRoot"));
$.writeln("TEMP == "+ $.getenv("TEMP"));
$.writeln("TMP == "+ $.getenv("TMP"));
$.writeln("USERDOMAIN == "+ $.getenv("USERDOMAIN"));
$.writeln("USERNAME == "+ $.getenv("USERNAME"));
$.writeln("USERPROFILE == "+ $.getenv("USERPROFILE"));
$.writeln("windir == "+ $.getenv("windir"));
It looks like this is a list of Win-only environment variables, and I'm on PS CS6, OSX.
Is there a way to get a Mac list?
Thank you!
Davide
Code: Select all$.writeln("ALLUSERSPROFILE == "+ $.getenv("ALLUSERSPROFILE"));
$.writeln("APPDATA == "+ $.getenv("APPDATA"));
$.writeln("CommonProgramFiles == "+ $.getenv("CommonProgramFiles"));
$.writeln("COMPUTERNAME == "+ $.getenv("COMPUTERNAME"));
$.writeln("ComSpec == "+ $.getenv("ComSpec"));
$.writeln("HOMEDRIVE == "+ $.getenv("HOMEDRIVE"));
$.writeln("HOMEPATH == "+ $.getenv("HOMEPATH"));
$.writeln("LOGONSERVER == "+ $.getenv("LOGONSERVER"));
$.writeln("NUMBER_OF_PROCESSORS == "+ $.getenv("NUMBER_OF_PROCESSORS"));
$.writeln("OS == "+ $.getenv("OS"));
$.writeln("Os2LibPath == "+ $.getenv("Os2LibPath"));
$.writeln("Path == "+ $.getenv("Path"));
$.writeln("PATHEXT == "+ $.getenv("PATHEXT"));
$.writeln("PROCESSOR_ARCHITECTURE == "+ $.getenv("PROCESSOR_ARCHITECTURE"));
$.writeln("PROCESSOR_IDENTIFIER == "+ $.getenv("PROCESSOR_IDENTIFIER"));
$.writeln("PROCESSOR_LEVEL == "+ $.getenv("PROCESSOR_LEVEL"));
$.writeln("PROCESSOR_REVISION == "+ $.getenv("PROCESSOR_REVISION"));
$.writeln("ProgramFiles == "+ $.getenv("ProgramFiles"));
$.writeln("SystemDrive == "+ $.getenv("SystemDrive"));
$.writeln("SystemRoot == "+ $.getenv("SystemRoot"));
$.writeln("TEMP == "+ $.getenv("TEMP"));
$.writeln("TMP == "+ $.getenv("TMP"));
$.writeln("USERDOMAIN == "+ $.getenv("USERDOMAIN"));
$.writeln("USERNAME == "+ $.getenv("USERNAME"));
$.writeln("USERPROFILE == "+ $.getenv("USERPROFILE"));
$.writeln("windir == "+ $.getenv("windir"));
It looks like this is a list of Win-only environment variables, and I'm on PS CS6, OSX.
Is there a way to get a Mac list?
Thank you!
Davide
-
Paul MR
Setting an environment variable with JS
$.setenv(); is a Photoshop variable, not an environment variable that exist for the duration of Photoshop session.
$.getenv(); will get a system or Photoshop variable.
To get a list on a Mac, open a terminal window and enter "set", same on a windows machine but from a dos prompt.
$.getenv(); will get a system or Photoshop variable.
To get a list on a Mac, open a terminal window and enter "set", same on a windows machine but from a dos prompt.
-
undavide
Setting an environment variable with JS
Thanks Paul!
I'm wondering what use one could do of PS variables set via $.setenv() (globals?)
Davide
I'm wondering what use one could do of PS variables set via $.setenv() (globals?)
Davide
-
Paul MR
Setting an environment variable with JS
It's great for passing information between scripts, this method has been used in some of the Deco scripts that are about.
It is also a way of setting a Photoshop variable from VBS etc. rather that writing to file and reading from that.
It is also a way of setting a Photoshop variable from VBS etc. rather that writing to file and reading from that.