1

In AppleScript, you can do something like:

set username to short user name of (system info)
set computername to host name of (system info)
set ethernet to primary Ethernet address of (system info)
set ipaddress to IPv4 address of (system info)
set osver to system version of (system info)

I'm not sure how I can access system info object. How do I do this in JXA (JavaScript AppleScript)? Thanks!

jl303
  • 1,461
  • 15
  • 27

1 Answers1

1

I use very little JavaScript in AppleScript, mostly with webpages to get and set information, however here’s what I can tell you about the AppleScript system info command used with JavaScript for the code you've shown.

The AppleScript system info command is a part of Standard Additions and can be accessed using the following example JavaScript code in Script Editor.

app = Application.currentApplication();
app.includeStandardAdditions = true;

var username        =   app.systemInfo().shortUserName;
var computername    =   app.systemInfo().hostName;
var ethernet        =   app.systemInfo().primaryEthernetAddress;
var ipaddress       =   app.systemInfo().ipv4Address;
var osver           =   app.systemInfo().systemVersion;

Have a look in the Standard Editions AppleScript Dictionary in the Library in Script Editor.

user3439894
  • 7,266
  • 3
  • 17
  • 28