Skip to main content
New Participant
December 21, 2014
Answered

How to get current username with script

  • December 21, 2014
  • 2 replies
  • 2709 views

I am trying to get the username for the current photoshop session. I have poured through the scripting documentation but I cant seem to find how to do it. In After Effects is as easy as doing

var username =  system.userName;

How ca I do the same in photoshop?

This topic has been closed for replies.
Correct answer xbytor2

$.getenv("USERNAME") works for Windows and it or something similar will work for OS X.

Edit:

$.getenv("USER") for OS X.

2 replies

fxjeaneAuthor
New Participant
December 21, 2014

I acutaly found a solution on another site. Here is how to get the value on a mac

var userNamePath = Folder('~').fsName;

var userName = userNamePath.substr(userNamePath.lastIndexOf('/')+1);

Cheers

xbytor2Correct answer
Inspiring
December 21, 2014

$.getenv("USERNAME") works for Windows and it or something similar will work for OS X.

Edit:

$.getenv("USER") for OS X.

fxjeaneAuthor
New Participant
December 21, 2014

Thanks for your prompt reply!

Quick question though, where do I find documentation on the $ object? I dont see it in the javascript docs.

Cheers

Inspiring
December 21, 2014

There's JavaScript Tools Guide pdf available for download.