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

Get MAC Address

Advocate ,
Jul 16, 2015 Jul 16, 2015

Hi,

is there a platform independent way to get the machine MAC Address via ExtendScript?

I've found this one but apparently it's Win only (and uses VBScript, which InDesign can call using app.doScript() which we don't have in PS)

Get network adapter Name/MAC/Speed | IndiSnip [InDesign® Snippets]

Thank you very much in advance,

Davide Barranca

---

www.davidebarranca.com

www.cs-extensions.com

TOPICS
Actions and scripting
1.4K
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

correct answers 1 Correct answer

Advisor , Jul 16, 2015 Jul 16, 2015

On Windows, do

    app.system("getmac > /tmp/mac"); $.sleep(1000);

and parse the output.

On OS X, do

   app.system("networksetup -listallhardwareports > /tmp/mac"); $.sleep(1000);

and parse the output.

The sleep() calls are because app.system() call executes the command line asynchronously.

I haven't tested it but it looks close.

Translate
Adobe
Advisor ,
Jul 16, 2015 Jul 16, 2015

On Windows, do

    app.system("getmac > /tmp/mac"); $.sleep(1000);

and parse the output.

On OS X, do

   app.system("networksetup -listallhardwareports > /tmp/mac"); $.sleep(1000);

and parse the output.

The sleep() calls are because app.system() call executes the command line asynchronously.

I haven't tested it but it looks close.

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
Advocate ,
Jul 17, 2015 Jul 17, 2015

Thank you x,

on the HTML Panel side I've also found this node module which seems to work pretty well too (even if ExtScript is safer): getmac

I've tested the OSX and works good, thanks! I assume the Win does too.

Davide

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 ,
Jul 17, 2015 Jul 17, 2015

$.os

if ($.os.charAt (0) == 'W') {

    alert("windows");

} else if ($.os.charAt (0) == 'M'){

    alert("mac");

} else {

    alert("whatever :-)");

}

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
Advocate ,
Jul 17, 2015 Jul 17, 2015

Hi Pedro,

I'm afraid I was asking about MAC Address, which is the unique ID of Network Interfaces 😉

(something like e4:ce:8f:5b:a7:fc)

Davide

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 ,
Jul 17, 2015 Jul 17, 2015
LATEST

Here I can't test it, but does any of this get it some where?

$.writeln("ALLUSERSPROFILE  == "+  $.getenv("ALLUSERSPROFILE"));

$.writeln("APPDATA  == "+  $.getenv("APPDATA"));

$.writeln("CommonProgramFiles  == "+  $.getenv("CommonProgramFiles"));

$.writeln("COMPUTERNAME  == "+  $.getenv("COMPUTERNAME"));

$.writeln("ComSpec  == "+  $.getenv("ComSpec"));

$.writeln("HOMEDRIVE  == "+  $.getenv("HOMEDRIVE"));

$.writeln("HOMEPATH  == "+  $.getenv("HOMEPATH"));

$.writeln("LOGONSERVER  == "+  $.getenv("LOGONSERVER"));

$.writeln("NUMBER_OF_PROCESSORS  == "+  $.getenv("NUMBER_OF_PROCESSORS"));

$.writeln("OS  == "+  $.getenv("OS"));

$.writeln("Os2LibPath  == "+  $.getenv("Os2LibPath"));

$.writeln("Path  == "+  $.getenv("Path"));

$.writeln("PATHEXT  == "+  $.getenv("PATHEXT"));

$.writeln("PROCESSOR_ARCHITECTURE  == "+  $.getenv("PROCESSOR_ARCHITECTURE"));

$.writeln("PROCESSOR_IDENTIFIER  == "+  $.getenv("PROCESSOR_IDENTIFIER"));

$.writeln("PROCESSOR_LEVEL  == "+  $.getenv("PROCESSOR_LEVEL"));

$.writeln("PROCESSOR_REVISION  == "+  $.getenv("PROCESSOR_REVISION"));

$.writeln("ProgramFiles  == "+  $.getenv("ProgramFiles"));

$.writeln("SystemDrive  == "+  $.getenv("SystemDrive"));

$.writeln("SystemRoot  == "+  $.getenv("SystemRoot"));

$.writeln("TEMP  == "+  $.getenv("TEMP"));

$.writeln("TMP  == "+  $.getenv("TMP"));

$.writeln("USERDOMAIN  == "+  $.getenv("USERDOMAIN"));

$.writeln("USERNAME  == "+  $.getenv("USERNAME"));

$.writeln("USERPROFILE  == "+  $.getenv("USERPROFILE"));

$.writeln("windir  == "+  $.getenv("windir"));

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