child_process.exec() - open executed program in interactive window
See original GitHub issueHi 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:
- Created 8 years ago
- Comments:9
Top GitHub Comments
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 🎱
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…