Skip to main content
Participating Frequently
April 16, 2020
Answered

Javascript to get my machine's name

  • April 16, 2020
  • 2 replies
  • 19817 views

Hello,

 

I'm trying to use javascript to get my machine's name: "FSMACLT31",

 

So far, the closest I could get to is the below:

 

Is there another magic word instead of "HOME" would do the trick? 

Thanks heaps for your help!

This topic has been closed for replies.
Correct answer Laubender

Hi SychevKA,

"computername" would only work on Windows, I think.

 

Unfortunately a lot of the old InDesign Scripting Forum is missing.

In 2011 there was a thread about this issue where someone, I think it was John Hawkinson, answered the question like this:

 

 

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);
	}

$.writeln( myUserName +"\r"+ mySysName );

 

 

Also see into this related thread that is still available:

 

$.getenv() on Mac
Jump_Over, Jan 17, 2017

https://community.adobe.com/t5/indesign/getenv-on-mac/td-p/8848527

 

Regards,
Uwe Laubender

( ACP )

2 replies

LaubenderCommunity ExpertCorrect answer
Community Expert
April 16, 2020

Hi SychevKA,

"computername" would only work on Windows, I think.

 

Unfortunately a lot of the old InDesign Scripting Forum is missing.

In 2011 there was a thread about this issue where someone, I think it was John Hawkinson, answered the question like this:

 

 

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);
	}

$.writeln( myUserName +"\r"+ mySysName );

 

 

Also see into this related thread that is still available:

 

$.getenv() on Mac
Jump_Over, Jan 17, 2017

https://community.adobe.com/t5/indesign/getenv-on-mac/td-p/8848527

 

Regards,
Uwe Laubender

( ACP )

tjinnzAuthor
Participating Frequently
April 17, 2020
var mySysName  = app.doScript('do shell script "hostname"', ScriptLanguage.APPLESCRIPT_LANGUAGE);

 

Awesome, this is exactly what I am after.

SychevKA
Inspiring
April 16, 2020

alert($.getenv('computername'))