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

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

Community Beginner ,
Feb 20, 2014 Feb 20, 2014

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
1.2K
Translate
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

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

Translate
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

Hi Siraj,  Thank you so much for the response.  We need to get the "DOMAIN" name not username.  Any help on this please...  Shaji

Translate
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

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

Translate
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

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

Translate
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

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

Translate
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

Hi Vandy,  I tried in the "terminal" as advised, but it did't work for MAC. Any other methods.  Shaji

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