Author Topic: Getting the home directory in jArchi  (Read 204 times)

Manj75

  • Senior Member
  • ****
  • Posts: 176
Getting the home directory in jArchi
« on: June 25, 2021, 17:47:41 PM »
I need to be able to get the user homedirectory, i.e. %userprofile% for win32 and $home for mac, if this is possible.

I was pointed to the $.process but not sure if it supports .env for environment variable.  I want to do something like:

Code: [Select]
process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];

but, I get undefined for $.process.env, so possible that it is not supported.

projetnumero9

  • Member
  • **
  • Posts: 18
Re: Getting the home directory in jArchi
« Reply #1 on: June 25, 2021, 18:53:05 PM »
JB pointed out something similar in: https://forum.archimatetool.com/index.php?topic=854.msg4709#msg4709

The following should do the trick:
Code: [Select]
console.log("New Archi Script");
var System = Java.type('java.lang.System'); 
console.log(System.getProperty("user.home")); 
console.log(System.getenv("USERPROFILE")); 

Manj75

  • Senior Member
  • ****
  • Posts: 176
Re: Getting the home directory in jArchi
« Reply #2 on: June 28, 2021, 16:10:24 PM »
Thanks PN9, this worked a treat