0

I have a requirement to call 4 vb script files(.vbs) one by one to execute few excel macros.lets say if i click on start button, it will trigger 1st .vbs task and once the 1st .vbs complete then it should move to 2nd .vbs call and it goes on. These all should be triggered by a single button click in web UI. How i can achieve this using nodejs? I have found this below package(using CMD) in the internet but i could not proceed how to achieve this with POST method using submit button and execute vbs files one by one.

const nodeCmd = require('node-cmd');
app.post('/', function (req, res) {


    res.sendFile(__dirname + '/progress.html');
    callvbs();

});
function callvbs()
{

    nodeCmd.get('callvbs.vbs');
    console.log('file created....');

}
1
  • You could write the excel macros in an actual excel file and run them upon opening the file. That way node just has to open the excel file with office. Alternatively, run the VBA directly using this answer stackoverflow.com/questions/47218117/run-vbs-script-with-node Commented Jan 24, 2020 at 14:17

1 Answer 1

0

First of all I am not sure what is full use case to execute vb script during an api call. I wouldn't suggest that. Look for other alternatives. If it is really required. You could use node-cmd with promises. someting like

const Promise = require("bluebird");
const cmd = require("node-cmd");

const getAsync = Promise.promisify(cmd.get, {"multiArgs": true, "context": cmd});

async function callScripts() {
  const script1Response = await getAsync("script1.vbs");
  console.log(script1Response);
  const script2Response = await getAsync("script2.vbs");
  console.log(script2Response);
  const script3Response = await getAsync("script3.vbs");
  console.log(script3Response);
  const script4Response = await getAsync("script4.vbs");
  console.log(script4Response);
}

app.post("/", async (req, res) => {
  await callScripts();
});


Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.