• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to get "Domain" name using "ExtendScript ToolKit"

Community Beginner ,
Feb 20, 2014 Feb 20, 2014

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

TOPICS
Scripting

Views

982

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 20, 2014 Feb 20, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 21, 2014 Feb 21, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 21, 2014 Feb 21, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 21, 2014 Feb 21, 2014

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???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 21, 2014 Feb 21, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 21, 2014 Feb 21, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 17, 2023 Mar 17, 2023

Copy link to clipboard

Copied

LATEST

Sir,

 

Variable name is "userdomain".

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

Here are the list of all the variables.

https://en.wikipedia.org/wiki/Environment_variable

 

 

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines