question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

child_process.exec() - open executed program in interactive window

See original GitHub issue

Hi fellow NWjs programmers,

I’m trying to solve/figure out the following: Is it possible to open a spawned external executable interactively. By external executable I mean: an executable that has not been packaged with the NWjs program I’m developing. I’m able to execute the external executable quite well, I see it in Windows task manager, however the programs does not appear and therefore I’m not able to interact with it. This is quite essential as the exe I’m calling is powershell with a specific script to the powershell.exe -File parameter. The script in -File is asking for input from the person running it, so again, interaction is needed. I can test and verify, that by using Shell I can open a file with its matching program. This gives me the impression that NWjs can fire external executables that will show their gui interactively, so either I’m doing something completely wrong or misunderstand what NWjs is capable of.

CODE EXAMPLE: var exec = require('child_process').exec; exec('powershell -noexit -File MailboxManagement_SetFullMbxPerms.ps1');

Looking forward to hear from you.

Thank you very much. /Larssb

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
larssbcommented, Feb 17, 2016

Almost did it…ended up doing:

var spawn = require('child_process').spawn; spawn('cmd.exe', ['/c', 'powershell.exe -noexit -File PATH TO FILE'], {detached: true});

Had to call powershell via cmd instead of PowerShell directly. The NodeJS doc also speaks about that and I tried the spawn method yesterday but without luck. However this is wonderful 👍

Finally it works - thank you very much for your great assistance.

Have a great day and good luck with the projects you are doing 🎱

0reactions
kucixcommented, Feb 17, 2016

I’m thinking. Powershell run’s noninteractive mode, because he is attached, he has redirected input/output streams.

Maybe it would help if you used a different method. Try spawn https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options And in options try detached: true. spawn('powershell.exe', ['-noexit', '-File MailboxManagement_SetFullMbxPerms.ps1'], {detached: true})

just an idea…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Launch Child Processes in Node.js - DigitalOcean
With our script in place, we can write a new Node.js module to execute it. This script will use execFile() to run the...
Read more >
Node.js Child Processes: Everything you need to know
There are four different ways to create a child process in Node: spawn() , fork() , exec() , and execFile() .
Read more >
Execute a Node.js child process after clicking a button
Here's how you can do this: On client side button click, make a request to a certain path in your express API; Your...
Read more >
Executing shell commands from Node.js - 2ality
In this blog post, we'll explore how we can execute shell commands from Node.js, via module 'node:child_process'.
Read more >
Child process | Node.js v19.3.0 Documentation
child_process.exec() : spawns a shell and runs a command within that shell, passing the stdout and stderr to a callback function when complete ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found