-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
child_process.exec() - open executed program in interactive window #4409
Comments
maybe is problem in exec. |
Hi @kucix, Thank you for replying. Just tried it. Same result. PowerShell shows up in task manager but not graphically with a window I can interact with. |
@kucix could it be the way I trigger it? Inside my HTML I have a button --> this button have an onClick tag --> this calls a function that resides inside a ` <title>Box Of Power</title> Click it! <script> function executeScript() { var execFile = require('child_process').execFile; execFile('powershell.exe', ['-noexit', '-File MailboxManagement_SetFullMbxPerms.ps1']); } </script> |
I don't know. Maybe someone else can help. |
hi @kucix, I just tested with notepad.exe, I can launch that and it opens and I can see the program running. This does not happen when calling PowerShell. Tried to lower the number of possible error causes by just calling powershell.exe only, without a reference to a script file. Still no interactive window. Did further troubleshooting and this might be because PowerShell figures its streams have been redirected and this makes it run in a non-interactive process.....references: powershell -File - // The above was taken from: https://www.bitvise.com/winsshd-usage-faq.html I’m guessing that the combination of ruby.exe allocating a console, running as LocalSystem within the service desktop and windows station, and the use of the -File powershell argument is causing this issue. It may be that we can avoid this issue either by specifying -InputFormat None, specifying the powershell command inline, or using a shell to redirect the file, e.g. cmd /c powershell.exe < foo.ps1 // The above was taken from: https://projects.puppetlabs.com/issues/22258 I tried the suggestions in the two posts but I can't get it to work. I hope someone can assists. Thank you very much. |
Looks like powershell feature. https://nodejs.org/api/child_process.html#child_process_child_stdin |
Hmmm yeah, good idea, but a little overboard considering the use case here. The use case is to use NWjs --> make a dashboard of a kind with web programming --> the dashboard should the show different management categories, for example Exchange, when clicking on a category you are taken to a sub-menu --> you then find the PowerShell you need to execute in order to solve the task at hand --> when clicking on the corresponding script button in the dashboard PowerShell should open in an interactive window - as the script is most likely needing input from the user executing it...... Thank you |
I'm thinking. Maybe it would help if you used a different method. just an idea... |
Almost did it.....ended up doing:
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 🎱 |
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
The text was updated successfully, but these errors were encountered: