Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

333
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda