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

276
Views
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
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!