Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

332
Views
Import System Environment Variable in Javascript

I come from python background, and can use os. environ['PATH'] to import an system environment variable. I don't see an similar feature in JavaScript. Is there anyway to import it and save it to a variable?

I am beginner in JS and started to learn. I am not using NodeJS but rather simple plain JS script inside HTML tags.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A programming language (usually) can not interact with the operating system on its own, it (usually) needs to import some extra library.

Python can not read the environment, but the module os can, so you can import os in Python and read the environment with os.environ['PATH'].

Similarily Javascript can not read the environment, but e.g. Node.js can, or deno, or wscript or cscript or mshta, or potentially any application that uses Javascript as a scripting language.

The browser (which supports Javascript as a scripting language) can not read the environment or filesystem on purpose, for security reasons.

conclusion

So you can not get system access from the browser. You need some other coding environment like node or deno or wscript, cscript, HTA, ...

(I don't have a Windows machine anymore and don't know if the following still works, I think I last tried in Win8)

If you are on Windows you could use HTA files, which can be written almost like normal HTML pages and support system access e.g. through ActiveXObject or other APIs, like:

var fso = new ActiveXObject("Scripting.Filesystemobject");
var wssh = new ActiveXObject("WScript.Shell");

HTA files are executed by mshta.exe, which I believe is/was basically an InternetExplorer 6 or something like that (so don't expect the latest JS/HTML features to work).

wscript.exe and cscript.exe can execute Javascript, but without HTML.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!