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

283
Vistas
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 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