I know this is security-wise an absolute No-Go. But my customer is going to use a SAPUI5 developed application in the browser within the intranet upon which my preinstalled browser extension will be invoked (using "matches") which should simply collect the PRINTER names on the local workstation and supplies back to the application which is to be used for further processes. I have the below node js code which return the printernames but how to run this in browser engine.
const { exec } = require('child_process');
exec('get-printer | Select-Object Name | ConvertTo-Json', { 'shell': 'powershell.exe' }, (error, stdout, stderr) => {
console.log(stdout);
})
You can't. You will need to expose your nodeJS code as an API which can be called by the browser environment. You could try exposing it as a REST endpoint inside a nodejs express app. Check this example: https://www.geeksforgeeks.org/how-to-connect-node-js-with-react-js/