tomas / dialog

Show native alert dialogs on Windows, OSX and Linux with Node.js.
57 stars 16 forks source link

Prevent console window from appearing on Windows #9

Closed daguej closed 6 years ago

daguej commented 7 years ago

On Windows, a very ugly empty console window appears while the dialog box is open if you use this module from a node process that was started as a detached process:

var child_process = require('child_process');
child_process.spawn('node', ['myscript.js'], {
  detached: true
});
// myscript.js
var dialog = require('dialog');
dialog.warn(...);

conhost window

Starting cscript detached solves this problem.

tomas commented 7 years ago

Good find, thanks. Does this affect the normal behaviour in any way? And does this happen on all Windows versions or only on a specific one?

daguej commented 7 years ago

Only tested in Windows 10 1703, but I'd be willing to bet that it happens on all Windows.

There is one way I know of that this does affect normal behavior -- previously, if the node process that called dialog exits, the cscript process is automatically terminated (the dialog disappears). This differs from nix platforms where the parent exiting does not* have an effect on child processes; the dialog does not disappear. (see deatched)

So this actually makes the module's Windows behavior consistent with its *nix behavior.

tomas commented 6 years ago

Sorry for the delay and thanks!