Skip to main content
nimazz
Participant
Jun 29, 2011 7:45 AM UTC
Answered

How to get the windows username in jsx

Hello,

I have a JSX script in "My Documents\Adobe Scripts" to make it trusted script. I have another text file I need to read from JSX. Since the location depends on logged in user, I need to find the windows username. If anyone know how to get the windows username from jsx please reply.

Thank you very much.

Regards

Nima.

This topic is closed to new replies. Start a new post to keep the conversation going.
tomaxxi
tomaxxiCorrect answer
Inspiring
Jun 29, 2011 7:58 AM UTC

Hey,

You can get username like this:

var myUsername = $.getenv('username');

You could also get My Documents folder like this:

var myDocFolder = Folder.myDocuments;

Hope that helps.

--

Marijan (tomaxxi)

http://tomaxxi.com/

10 replies

tomaxxi
tomaxxiCorrect answer
Inspiring
Jun 29, 2011 7:58 AM UTC

Hey,

You can get username like this:

var myUsername = $.getenv('username');

You could also get My Documents folder like this:

var myDocFolder = Folder.myDocuments;

Hope that helps.

--

Marijan (tomaxxi)

http://tomaxxi.com/

Translate
Inspiring
Jul 13, 2011 9:46 PM UTC

How about the username on a Mac?

Translate
கற_பன___Imagine_
Inspiring
Nov 11, 2011 8:19 AM UTC

Well, which system name? There are a few different ones. I'd use

app.doScript('do shell script "hostname"', ScriptLanguage.APPLESCRIPT_LANGUAGE);

But you can also do tricks in the filesystem with resolving : paths...


Thank you so much,

I've used the file system tricks for getting the exact results.

if (File.fs == "Windows" ) {

    var myUserName  = $.getenv('username');

    var mySysName  = $.getenv('computername');

    }

else if (File.fs == "Macintosh") {

           var myUserName  = $.getenv('USER');

           var mySysName  = app.doScript('do shell script "hostname"', ScriptLanguage.APPLESCRIPT_LANGUAGE);

    }

Thanks once again........

Translate
nimazz
nimazzAuthor
Participant
Jun 29, 2011 7:54 AM UTC

Hello,

I found the answer .

alert ($.getenv("USERNAME"));

this works fine.

Regards

Translate