0

I have a small vbs file which i use to focus a window on my windows OS.

Dim ObjShell :Set ObjShell = CreateObject("Wscript.Shell")
ObjShell.AppActivate(WScript.Arguments.Item(0))

i run this script by passing a commandline argument. ex - focuser.vbs "Notepad"

it works perfectly fine when i run it through my commandline(cmd).

But i want to execute this file from a node/express server. Here is the code which im using to do so.

const express = require('express');
const app = express(); 
const shell = require('shelljs')

app.get("/",(req,res,next)=>{
shell.exec('focuser.vbs "Notepad"')
res.send("Automation Complete");
});

app.listen(9111,()=>{
    console.log("listening on port 9111");   
});

It does work and it does run the vbs file. but my window doesn't get focused.

how do i know whether the script is getting executed or not? ans - that particular window's icon blinks on my task bar.

Why is this happening ? and how do i make that window popup on my screen so that i can interact with it?

  • Does this answer your question? [Run .vbs script with node](https://stackoverflow.com/questions/47218117/run-vbs-script-with-node) – user692942 Jul 24 '21 at 00:14

0 Answers0