Copy link to clipboard
Copied
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.
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/
Copy link to clipboard
Copied
Hello,
I found the answer .
alert ($.getenv("USERNAME"));
this works fine.
Regards
Copy link to clipboard
Copied
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/
Copy link to clipboard
Copied
Hi Marijan,
That's was helpful. thanks for the quick response.
Regards
Nima
Copy link to clipboard
Copied
How about the username on a Mac?
Copy link to clipboard
Copied
You can use $.getenv('USER'); I can't help feeling there should be a platform-independent solution though...
Copy link to clipboard
Copied
Thanks!
I was pretty surprised myself that it wasn't.
Copy link to clipboard
Copied
Hi,
How to get the system name on mac?
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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........
Copy link to clipboard
Copied
Thank you so much, I've used the file system tricks for getting the exact results.
Not quite what I meant. Try this:
(new File("/..").displayName)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now