Copy link to clipboard
Copied
Hi all, We got a requirement to get the "Domain" name using JavaScripting. I am using MAC OS 10.6.8 with Indesign CS 6. I tried using the below code to get the "USER" name, but not able to get the "Domain" name. alert($.getenv("USER")) Is there is any other method to get the "Domain" name, please suggest. Thanks, Shaji
Copy link to clipboard
Copied
Hi Shaji,
May the below coding will helpful for you...
var myAppleScript3 = 'tell application "Finder"\r';
myAppleScript3 += 'do shell script "whoami"\r';
myAppleScript3 += 'end tell\r';
var username =app.doScript(myAppleScript3, ScriptLanguage.applescriptLanguage);
alert("username: "+ username);
Thanks
Siraj
Copy link to clipboard
Copied
Hi Siraj, Thank you so much for the response. We need to get the "DOMAIN" name not username. Any help on this please... Shaji
Copy link to clipboard
Copied
Hope this may help you,
var batCreation = new File("/D/test.bat");
var batCode = 'cd D:\\ \n D: \n echo %USERDOMAIN%' + ' > ' +'domain.txt';
batCreation .open( "w" );
batCreation.writeln(batCode);
batCreation.close();
batCreation.execute();
var result = File('D:\\domain.txt');
while(!result.exists){ $.sleep(5); }
result.open( 'r' );
var domainName = result.read();
result.close();
result.remove();
batCreation.remove();
alert(domainName);
Vandy
Copy link to clipboard
Copied
Hi vandy,
Its working in windows, but how to get in Mac?
And also we can use simply as "alert($.getenv("userdomain"))". Its only for windows... Mac???
Copy link to clipboard
Copied
Oops sorry...
I don't have Mac but I checked some manual it gives the below result. Hope this may help you.
In Mac terminal use Sys.getenv(), but I didn't test it
Vandy
Copy link to clipboard
Copied
Hi Vandy, I tried in the "terminal" as advised, but it did't work for MAC. Any other methods. Shaji
Copy link to clipboard
Copied
Sir,
Variable name is "userdomain".
alert($.getenv ("USERDOMAIN"));
Here are the list of all the variables.
https://en.wikipedia.org/wiki/Environment_variable