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

280
Visualizações
Need to run bat file through onclick using node

I'm trying to create what I think should be a very simple thing. I plan to use something like nexe to eventually turn this into an exe file. All I need it to do is open a page I built, that has button, and when you push that button it runs a .bat file I have stored locally.

This is all running on a virtual machine so i'm not worried about security.

So I need it to open a command prompt, navigate to the location of the bat file, and then open it. I just have a skeleton. Sorry for the dumb question- please help me learn.

<body>
<div id="backDiv">
<button onClick="execute" id="button">RUN THAT BAT</button>
</div>

<script type="text/javascript">

function execute(){

const { spawn } = require('child_process');
const bat = spawn('cmd.exe', ['/c', 'fileiwanttorun.bat']);

bat.stdout.on('data', (data) => {
  console.log(data.toString());
});

bat.stderr.on('data', (data) => {
  console.error(data.toString());
});

bat.on('exit', (code) => {
  console.log(`Child exited with code ${code}`);
});
}

</script>
</body>
about 4 years ago · Juan Pablo Isaza
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