Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

334
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda